The way python does it is different. There's no "typethon". The python grammar was simply extended to allow any random expression as a "type".
In fact:
x: print("hi") = 4
is valid python, and it does print "hi" without even so much as a warning. Personally, I don't think "print(hi)" should be a valid type.The fact that the typescript implementation does not run typescript directly, and cPython does not type check before running the code, are both implementation details.
Typescript is just a better type system on top of javascript than python's type system is on top of untyped python, because typescript is a cohesive design rather than a collection or random stuff accumulated over time.
There's no reason that couldn't have happened for python, it just didn't.
And it isn't:
a.py:1: error: Invalid type comment or annotation [valid-type]
a.py:1: note: Suggestion: use print[...] instead of print(...)
Found 1 error in 1 file (checked 1 source file)As stated in the typing documentation [0]: "the only legal parameters for type are classes, Any, type variables, and unions of any of these types".
I can put that in main.py and do `python3 main.py` and it will simply run fine.
What is the point of this whole system if it's not enforced?
If you don't want type checking, don't run mypy.
I don't see what's so difficult. If it was technically possible to run programs that have type errors in other languages, they would have the option to ignore type errors too, because it's convenient.
Typescript also ignores errors (generating js output for you to run) by default, so what's the point if it's not enforced?
PHP has been able to add in more typing over the same period of time and has seemed to avoid these Python problems.
Python also broke backwards compatibility with their v3 release years ago. Unsure why breaking backward compatibility is being called out here(?).
But yeah, overall, it's struck me that PHP has introduced more and stricter typing rules with surprisingly little impact (compared to what could have been, of course).
Do you mean mypy is optional?
At the risk of opening a can of worms here, what's "horrible"?
In your own PHP code, you can get by without any typing at all. If/when you start to use 3rd party libraries, that may become a factor, though off the top of my head I can't think of a show stopper.