You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With Mypy 0.590 (This was also the case with previous version), using the flag --strict-optional
Would it be possible to handle a different type for the getter/setter of properties.
In below code example I would expect no Mypy errors, but there are errors each time the property message is assigned a None value, even though the setter arguments list mention that message may be provided a None.
fromtypingimportOptionalclassHello(object):
@propertydefmessage(self) ->str:
"""Get the message (Never None)."""returnself.__message@message.setterdefmessage(self, value: Optional[str]) ->None:
"""Set the message (Set to empty string if None is provided)."""self.__message=""ifvalueisNoneelsestr(value)
def__init__(self) ->None:
# Initialize default values of the properties:self.message=None# error: Incompatible types in assignment (expression has type "None", variable has type "str")x=Hello()
x.message="World !"a="Hello "+x.messagex.message=None# error: Incompatible types in assignment (expression has type "None", variable has type "str")
The text was updated successfully, but these errors were encountered:
With Mypy 0.590 (This was also the case with previous version), using the flag --strict-optional
Would it be possible to handle a different type for the getter/setter of properties.
In below code example I would expect no Mypy errors, but there are errors each time the property message is assigned a None value, even though the setter arguments list mention that message may be provided a None.
The text was updated successfully, but these errors were encountered: