File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -981,6 +981,10 @@ def expand_and_bind_callable(
981
981
assert isinstance (expanded , CallableType )
982
982
if var .is_settable_property and mx .is_lvalue and var .setter_type is not None :
983
983
# TODO: use check_call() to infer better type, same as for __set__().
984
+ if not expanded .arg_types :
985
+ # This can happen when accessing invalid property from its own body,
986
+ # error will be reported elsewhere.
987
+ return AnyType (TypeOfAny .from_error )
984
988
return expanded .arg_types [0 ]
985
989
else :
986
990
return expanded .ret_type
Original file line number Diff line number Diff line change @@ -8726,3 +8726,16 @@ class Fields:
8726
8726
reveal_type(Fields.bool_f) # N: Revealed type is "__main__.BoolField"
8727
8727
reveal_type(Fields.int_f) # N: Revealed type is "__main__.NumField"
8728
8728
reveal_type(Fields.custom_f) # N: Revealed type is "__main__.AnyField[__main__.Custom]"
8729
+
8730
+ [case testRecursivePropertyWithInvalidSetterNoCrash]
8731
+ class NoopPowerResource:
8732
+ _hardware_type: int
8733
+
8734
+ @property
8735
+ def hardware_type(self) -> int:
8736
+ return self._hardware_type
8737
+
8738
+ @hardware_type.setter
8739
+ def hardware_type(self) -> None: # E: Invalid property setter signature
8740
+ self.hardware_type = None # Note: intentionally recursive
8741
+ [builtins fixtures/property.pyi]
You can’t perform that action at this time.
0 commit comments