4 ms·
> Python doesn't even have constructs for making a variable immutable. recent addition into `typing_extensions` allows that: from typing_extensions import Fin
by yedpodtrzitko 8y ago
> Python doesn't even have constructs for making a variable immutable.
recent addition into `typing_extensions` allows that:
from typing_extensions import Final
immutable_str: Final[str] = "cant change me"
mypy will then notice you in case the variable has been changed somewhere.
> Also, I think type hints aren't a in the right direction, comparing it with type inference...
that's quite vague statement, but mypy supports type inference to some extent - if you'll initalize a list with some strings in it, it will infere the type as list of strings etc