Also, I think type hints aren't a in the right direction, comparing it with type inference and generics in Haskell, for instance.
Is there any alternative?
Also, I think type hints aren't a in the right direction, comparing it with type inference and generics in Haskell, for instance.
Is there any alternative?
2 comments
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
http://mypy-lang.org
Perhaps the solution would be a full blown programming language which transpiled to Python the same way Typescript does. So, MyPi, but much more developed: interfaces, type inference, generics... Having access to all the Python libraries.