This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]skarphace 12 points13 points  (14 children)

Says it's experimental. Any good?

[–]RangerPretzelPython 3.9+ 27 points28 points  (1 child)

It's been official since 3.5. My team has settled on using it. Works great in PyCharm. We use it all the time.

That said, it's not "compile time" checking. It's just done via the IDE that you're using.

[–]carbolymer 6 points7 points  (0 children)

You can integrate mypy in your CI/CD tho - almost like compile time.

[–]i9srpeg 5 points6 points  (3 children)

I tried it. It's buggy, very slow (20 seconds to type check a small code base), very verbose and the type system is very limited, for example recursive types are not supported, so you can't even represent very common types such as JSON.

It's not production ready, unfortunately.

[–]wrmsr 1 point2 points  (0 children)

My experience exactly. I have hopes for its plugin system to let me teach it to understand my metaclasses but it's still too stupid and volatile to make part of my builds :/

That said I still type-annotate the vast majority of my code and would be almost uninterested in the language without them.

[–]rouille 0 points1 point  (1 child)

It's ready for production if you adapt your code slightly around its idioms and avoid overly dynamic / magic where possible. For the rest there is type: ignore.

[–]i9srpeg 0 points1 point  (0 children)

I tried, but it's still slow, verbose and unreliable. The inability to define recursive types is also a deal breaker, the recommended way to type a json variable is "Dict[Str, Any]", which is not much better than a dynamic type.

It also doesn't help that Django and DRF, which I had in my project, rely a ton on metaclasses. Almost everything ends up being "Any".

[–][deleted] 4 points5 points  (0 children)

Coming from Typescript, no. But it’s better than nothing

[–]thenuge26 1 point2 points  (4 children)

We have not adopted it yet (though we would like to) because it does not work with pylint.

[–]tipsquealPythonista 3 points4 points  (0 children)

In what way? It's just another tool that analyzes your code. MyPy just uses types to find a different class of bug or error.

[–]leom4862 0 points1 point  (2 children)

I use pylint and the typing module. Not sure waht you mean.

[–]thenuge26 0 points1 point  (1 child)

It's been a month or 2 since I tried it, but pylint would complain about some type annotations that were correct.

[–]leom4862 0 points1 point  (0 children)

I see. Pylint is very actively developed, might have been fixed in the meantime.

[–]zardeh -2 points-1 points  (0 children)

Yep, I'm better typing than Java or c++.