I'm new to python and experimenting with type hints, however they only seem to work in some instances. They seem to work as expected on the property return type, however when I try to assign an integer to a string value (i.e. self._my_string = 4), I get no issues reported.
class TypeHintTest(object):
_my_string: str
def __init__(self):
self._my_string = 4 # no error
@property
def as_int(self) -> int:
return self._my_string # Error : expected int got str
The resulting object then contains an int value (as expected).
I'm using pyCharm 2018.3.2 Community edition, the interpreter is 3.6
The following question seems to be similar, but the solution of changing the constructor to def __init__(self) -> None
does not change anything.
Python: All type hints errors in subclass constructure seems ignored