@@ -25,7 +25,7 @@ class PerTypeHintState:
25
25
"""
26
26
27
27
# A hint type for which this state is for; an empty string if a hint doesn't explicitly specify types.
28
- type : str
28
+ type : bytes
29
29
# Only the base name, not a full path - it's a small optimization (and we anyway need to store the tmp dir in the
30
30
# HintState).
31
31
hints_file_name : Path
@@ -62,7 +62,7 @@ class SpecialHintState:
62
62
another - hence there's no underlying_state here.
63
63
"""
64
64
65
- type : str
65
+ type : bytes
66
66
hints_file_name : Path
67
67
hint_count : int
68
68
@@ -97,10 +97,10 @@ def __repr__(self):
97
97
parts = []
98
98
for i , s in enumerate (self .per_type_states ):
99
99
mark = '[*]' if i == self .ptr and len (self .per_type_states ) > 1 else ''
100
- type_s = s .type + ': ' if s .type else ''
100
+ type_s = s .type . decode () + ': ' if s .type else ''
101
101
parts .append (f'{ mark } { type_s } { s .underlying_state .compact_repr ()} ' )
102
102
for s in self .special_hints :
103
- parts .append (f'{ s .type } : { s .hint_count } ' )
103
+ parts .append (f'{ s .type . decode () } : { s .hint_count } ' )
104
104
return f'HintState({ ", " .join (parts )} )'
105
105
106
106
def real_chunk (self ) -> int :
@@ -134,7 +134,7 @@ def advance(self) -> Union[HintState, None]:
134
134
special_hints = self .special_hints ,
135
135
)
136
136
137
- def advance_on_success (self , type_to_bundle : Dict [str , HintBundle ]):
137
+ def advance_on_success (self , type_to_bundle : Dict [bytes , HintBundle ]):
138
138
sub_states = []
139
139
# Advance all previously present hint types' substates. We ignore any newly appearing hint types because it's
140
140
# nontrivial to distinguish geniunely new hints from those that we (unsuccessfully) checked.
@@ -152,7 +152,7 @@ def advance_on_success(self, type_to_bundle: Dict[str, HintBundle]):
152
152
tmp_dir = self .tmp_dir , per_type_states = tuple (sub_states ), ptr = 0 , special_hints = self .special_hints
153
153
)
154
154
155
- def hint_bundle_paths (self ) -> Dict [str , Path ]:
155
+ def hint_bundle_paths (self ) -> Dict [bytes , Path ]:
156
156
return {
157
157
substate .type : self .tmp_dir / substate .hints_file_name
158
158
for substate in self .per_type_states + self .special_hints
@@ -186,7 +186,7 @@ def generate_hints(
186
186
) -> HintBundle :
187
187
raise NotImplementedError (f"Class { type (self ).__name__ } has not implemented 'generate_hints'!" )
188
188
189
- def input_hint_types (self ) -> List [str ]:
189
+ def input_hint_types (self ) -> List [bytes ]:
190
190
"""Declares hint types that are consumed by this pass as inputs.
191
191
192
192
Intended to be overridden by subclasses, in cases where dependencies between passes need to be implemented:
@@ -196,7 +196,7 @@ def input_hint_types(self) -> List[str]:
196
196
"""
197
197
return []
198
198
199
- def output_hint_types (self ) -> List [str ]:
199
+ def output_hint_types (self ) -> List [bytes ]:
200
200
"""Declares hint types that are produced by this pass.
201
201
202
202
A pass must override this method if it produces hints with a nonempty type (the "t" field).
@@ -304,16 +304,16 @@ def advance_on_success_from_hints(self, bundle: HintBundle, state: HintState) ->
304
304
store_hints_per_type (state .tmp_dir , type_to_bundle )
305
305
return state .advance_on_success (type_to_bundle )
306
306
307
- def backfill_pass_names (self , type_to_bundle : Dict [str , HintBundle ]) -> None :
307
+ def backfill_pass_names (self , type_to_bundle : Dict [bytes , HintBundle ]) -> None :
308
308
for bundle in type_to_bundle .values ():
309
309
if not bundle .pass_name :
310
310
bundle .pass_name = repr (self )
311
311
312
312
313
- def store_hints_per_type (tmp_dir : Path , type_to_bundle : Dict [str , HintBundle ]) -> Dict [str , Path ]:
313
+ def store_hints_per_type (tmp_dir : Path , type_to_bundle : Dict [bytes , HintBundle ]) -> Dict [bytes , Path ]:
314
314
type_to_file_name = {}
315
315
for type , sub_bundle in type_to_bundle .items ():
316
- file_name = Path (HINTS_FILE_NAME_TEMPLATE .format (type = type ))
316
+ file_name = Path (HINTS_FILE_NAME_TEMPLATE .format (type = type . decode () ))
317
317
store_hints (sub_bundle , tmp_dir / file_name )
318
318
type_to_file_name [type ] = file_name
319
319
return type_to_file_name
0 commit comments