6060 get_proper_type ,
6161 is_named_instance ,
6262)
63- from mypy .typestate import SubtypeKind , TypeState
63+ from mypy .typestate import SubtypeKind , type_state
6464from mypy .typevars import fill_typevars_with_any
6565from mypy .typevartuples import extract_unpack , fully_split_with_mapped_and_template
6666
@@ -154,7 +154,7 @@ def is_subtype(
154154 options ,
155155 }
156156 ), "Don't pass both context and individual flags"
157- if TypeState .is_assumed_subtype (left , right ):
157+ if type_state .is_assumed_subtype (left , right ):
158158 return True
159159 if mypy .typeops .is_recursive_pair (left , right ):
160160 # This case requires special care because it may cause infinite recursion.
@@ -174,7 +174,7 @@ def is_subtype(
174174 # B = Union[int, Tuple[B, ...]]
175175 # When checking if A <: B we push pair (A, B) onto 'assuming' stack, then when after few
176176 # steps we come back to initial call is_subtype(A, B) and immediately return True.
177- with pop_on_exit (TypeState .get_assumptions (is_proper = False ), left , right ):
177+ with pop_on_exit (type_state .get_assumptions (is_proper = False ), left , right ):
178178 return _is_subtype (left , right , subtype_context , proper_subtype = False )
179179 return _is_subtype (left , right , subtype_context , proper_subtype = False )
180180
@@ -215,11 +215,11 @@ def is_proper_subtype(
215215 ignore_uninhabited ,
216216 }
217217 ), "Don't pass both context and individual flags"
218- if TypeState .is_assumed_proper_subtype (left , right ):
218+ if type_state .is_assumed_proper_subtype (left , right ):
219219 return True
220220 if mypy .typeops .is_recursive_pair (left , right ):
221221 # Same as for non-proper subtype, see detailed comment there for explanation.
222- with pop_on_exit (TypeState .get_assumptions (is_proper = True ), left , right ):
222+ with pop_on_exit (type_state .get_assumptions (is_proper = True ), left , right ):
223223 return _is_subtype (left , right , subtype_context , proper_subtype = True )
224224 return _is_subtype (left , right , subtype_context , proper_subtype = True )
225225
@@ -445,14 +445,14 @@ def visit_instance(self, left: Instance) -> bool:
445445 if isinstance (right , TupleType ) and mypy .typeops .tuple_fallback (right ).type .is_enum :
446446 return self ._is_subtype (left , mypy .typeops .tuple_fallback (right ))
447447 if isinstance (right , Instance ):
448- if TypeState .is_cached_subtype_check (self ._subtype_kind , left , right ):
448+ if type_state .is_cached_subtype_check (self ._subtype_kind , left , right ):
449449 return True
450450 if not self .subtype_context .ignore_promotions :
451451 for base in left .type .mro :
452452 if base ._promote and any (
453453 self ._is_subtype (p , self .right ) for p in base ._promote
454454 ):
455- TypeState .record_subtype_cache_entry (self ._subtype_kind , left , right )
455+ type_state .record_subtype_cache_entry (self ._subtype_kind , left , right )
456456 return True
457457 # Special case: Low-level integer types are compatible with 'int'. We can't
458458 # use promotions, since 'int' is already promoted to low-level integer types,
@@ -589,7 +589,7 @@ def check_mixed(
589589 ):
590590 nominal = False
591591 if nominal :
592- TypeState .record_subtype_cache_entry (self ._subtype_kind , left , right )
592+ type_state .record_subtype_cache_entry (self ._subtype_kind , left , right )
593593 return nominal
594594 if right .type .is_protocol and is_protocol_implementation (
595595 left , right , proper_subtype = self .proper_subtype
@@ -978,7 +978,7 @@ def f(self) -> A: ...
978978 if skip is None :
979979 skip = []
980980 # We need to record this check to generate protocol fine-grained dependencies.
981- TypeState .record_protocol_subtype_check (left .type , right .type )
981+ type_state .record_protocol_subtype_check (left .type , right .type )
982982 # nominal subtyping currently ignores '__init__' and '__new__' signatures
983983 members_not_to_check = {"__init__" , "__new__" }
984984 members_not_to_check .update (skip )
@@ -1078,7 +1078,7 @@ def named_type(fullname: str) -> Instance:
10781078 subtype_context = SubtypeContext (ignore_pos_arg_names = ignore_names ),
10791079 proper_subtype = proper_subtype ,
10801080 )
1081- TypeState .record_subtype_cache_entry (subtype_kind , left , right )
1081+ type_state .record_subtype_cache_entry (subtype_kind , left , right )
10821082 return True
10831083
10841084
0 commit comments