3 ms·
I tried mypy when I first started into type checking in Python back when I was trying to do Python in VS Code and I discovered that mypy is a time-sucking anti-
by Lendal 4y ago
I tried mypy when I first started into type checking in Python back when I was trying to do Python in VS Code and I discovered that mypy is a time-sucking anti-productivity disaster that needs to die in a fire.
When I started learning PyCharm though, I discovered that type checking can actually work well in Python and it is not a waste of time at all. So I advise people now that unless you're using PyCharm, do not waste any time on type checking Python. In which case, have at it. I love it. PyCharm is really the only way to do type-checking productively right now.
- dgellow 4y agoIf you use VSCode and Pylance (Microsoft python language server) you don’t need to setup Mypy, you can enable type checking in user settings and it will use its own engine for type analysis. You have two modes, basic and strict. I would recommend to try out if you can, the experience is quite good. I personally find “strict” too strict for the current state of python, but “basic” is already very helpful. The developer experience is still subpar when compared to Typescript but it’s improving fast (but I mean, typescript with VSCode has one of the best developer experience I’ve ever seen).
- deleted 4y ago[deleted]
- ainar-g 4y agoCould you elaborate on mypy? I'm not a Python developer (and I really have much more experience with statically typed languages), but if I ever had to maintain a Python codebase, I'd assume that adding mypy and type annotations would be among the first things I'd do, so it's a bit of a surprise to read that.
- kstrauser 4y agoI love mypy. It's fine, if sometimes a little alarming when you aim it at a previously-untyped codebase. In my case, it turned up plenty of type errors that probably never became a problem in production, but very well could've. It's also a nice thing to put in a CI pipeline to block new code errors.
- Lendal 4y agoI spent a lot of time trying to configure pypy in VS Code, time that I didn't have to spend in other languages such as TypeScript, and I never did get it working as well as it does in PyCharm. PyCharm comes already configured. You don't have to do anything for typing. Works out of the box. VS Code is like that with TypeScript but not for Python. That was a couple of years back so maybe it's different today. I hear VS Code's PyLance extension works but I've already made the switch to PyCharm. I might try it out later.