File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change 2020 ProperType ,
2121 TupleType ,
2222 Type ,
23- TypeGuardedType ,
2423 TypeOfAny ,
2524 TypeType ,
2625 TypeVarType ,
@@ -278,10 +277,7 @@ def update_from_options(self, frames: list[Frame]) -> bool:
278277 possible_types = []
279278 for t in resulting_values :
280279 assert t is not None
281- if isinstance (t .type , TypeGuardedType ):
282- possible_types .append (t .type .type_guard )
283- else :
284- possible_types .append (t .type )
280+ possible_types .append (t .type )
285281 if len (possible_types ) == 1 :
286282 # This is to avoid calling get_proper_type() unless needed, as this may
287283 # interfere with our (hacky) TypeGuard support.
Original file line number Diff line number Diff line change @@ -117,7 +117,10 @@ def narrow_declared_type(declared: Type, narrowed: Type) -> Type:
117117 """Return the declared type narrowed down to another type."""
118118 # TODO: check infinite recursion for aliases here.
119119 if isinstance (narrowed , TypeGuardedType ):
120- # A type guard forces the new type even if it doesn't overlap the old.
120+ # A type guard forces the new type even if it doesn't overlap the old...
121+ if is_proper_subtype (declared , narrowed .type_guard , ignore_promotions = True ):
122+ # ...unless it is a proper supertype of declared type.
123+ return declared
121124 return narrowed .type_guard
122125
123126 original_declared = declared
You can’t perform that action at this time.
0 commit comments