File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -7755,11 +7755,8 @@ def get_isinstance_type(self, expr: Expression) -> list[TypeRange] | None:
7755
7755
types .append (TypeRange (typ , is_upper_bound = False ))
7756
7756
else : # we didn't see an actual type, but rather a variable with unknown value
7757
7757
return None
7758
- if not types :
7759
- # this can happen if someone has empty tuple as 2nd argument to isinstance
7760
- # strictly speaking, we should return UninhabitedType but for simplicity we will simply
7761
- # refuse to do any type inference for now
7762
- return None
7758
+ # Note: types can be an empty list, for example in `isinstance(x, ())`,
7759
+ # which always returns False at runtime.
7763
7760
return types
7764
7761
7765
7762
def is_literal_enum (self , n : Expression ) -> bool :
@@ -8003,6 +8000,8 @@ def conditional_types(
8003
8000
None means no new information can be inferred.
8004
8001
If default is set it is returned instead.
8005
8002
"""
8003
+ if proposed_type_ranges is None :
8004
+ return current_type , default
8006
8005
if not proposed_type_ranges :
8007
8006
return UninhabitedType (), default
8008
8007
You can’t perform that action at this time.
0 commit comments