Python has an optional typing system which helps your IDE complete things and can be checked with tools like<p><a href="https://mypy.readthedocs.io/en/stable/index.html" rel="nofollow">https://mypy.readthedocs.io/en/stable/index.html</a><p>Plus there are compilers which can make faster code if you add static types<p><a href="https://cython.readthedocs.io/en/latest/src/quickstart/cythonize.html" rel="nofollow">https://cython.readthedocs.io/en/latest/src/quickstart/cytho...</a>
It's true that python has support for typing, and I do find that mypy helps produce better python code.<p>But I think a meaningful issue is that python's rich ecosystem of datascience and ML tooling often is at odds with meaningful type annotations. Roughly, you can end up with signatures that indicate that a value is a DataFrame or an ndarray or whatever, but there are a bunch of implicit assumptions on what columns are defined, or what how the shapes of two ndarrays line up, etc. It's easy for a codebase to end up paying the upfront cost of providing annotations, but without actually getting an improved ability to reason about or refactor code.
Python 3 has types and you can use Pydantic for validation.<p><a href="https://docs.pydantic.dev" rel="nofollow">https://docs.pydantic.dev</a>
In the abstract we have Psalm for PHP which I think is likely to eventually get rolled into PHP’s native type system. It’s so robust the major IDEs haven’t fully implemented it yet.<p>It doesn’t turn PHP into Haskell or anything but huge swaths of bugs are eliminated.
As other mentioned, Python has already some tools around strong typing.<p>However they aren’t as extensive as TypeScript is to JavaScript. The community is also not much into types so you don’t have collections like Definitely Typed.<p>But the need exists and I guess it’s a matter of time until a tool becomes as popular and complete as typescript.