Good. Never been able to make mypy work as intended.
Python
Welcome to the Python community on the programming.dev Lemmy instance!
π Events
Past
November 2023
- PyCon Ireland 2023, 11-12th
- PyData Tel Aviv 2023 14th
October 2023
- PyConES Canarias 2023, 6-8th
- DjangoCon US 2023, 16-20th (!django π¬)
July 2023
- PyDelhi Meetup, 2nd
- PyCon Israel, 4-5th
- DFW Pythoneers, 6th
- Django Girls Abraka, 6-7th
- SciPy 2023 10-16th, Austin
- IndyPy, 11th
- Leipzig Python User Group, 11th
- Austin Python, 12th
- EuroPython 2023, 17-23rd
- Austin Python: Evening of Coding, 18th
- PyHEP.dev 2023 - "Python in HEP" Developer's Workshop, 25th
August 2023
- PyLadies Dublin, 15th
- EuroSciPy 2023, 14-18th
September 2023
- PyData Amsterdam, 14-16th
- PyCon UK, 22nd - 25th
π Python project:
- Python
- Documentation
- News & Blog
- Python Planet blog aggregator
π Python Community:
- #python IRC for general questions
- #python-dev IRC for CPython developers
- PySlackers Slack channel
- Python Discord server
- Python Weekly newsletters
- Mailing lists
- Forum
β¨ Python Ecosystem:
π Fediverse
Communities
- #python on Mastodon
- c/django on programming.dev
- c/pythorhead on lemmy.dbzer0.com
Projects
- PythΓΆrhead: a Python library for interacting with Lemmy
- Plemmy: a Python package for accessing the Lemmy API
- pylemmy pylemmy enables simple access to Lemmy's API with Python
- mastodon.py, a Python wrapper for the Mastodon API
Feeds
I don't think a powerful type system can be added to python effectively. Even more convinced of this after reading "minimize false positives".
Otoh, how strong of a type system is required for effective development? Probably what can be shoehorned into python tbh.
How powerful do you want it? Python's type system is actually pretty good already and relatively sound when checked with Pyright (not Mypy though).
It's not Typescript-level, but it's better than e.g. Java or C++.
The main problem is Python developers writing code that can't be statically type checked. E.g. using magically generate method names via __dict__
or whatever (I think lxml does that).
I'm on the more powerful the better side. So for me, Scala is the weakest type system I like working with.
Practically tho: aside from the issues you mention, the type checker for python would be a great aid for a broader range of developers than myself!
i don't believe it's possible either. For example the tree walker of the ast module takes the node passed to it, checks its type, gets its name, then looks for the method with that dynamically looked up name in your implementation of the tree walker and if it does (the user might not have implemented a visit method for that type of node), calls it and passes the node to it. All of this at runtime.
I had a quick look and am already afraid that they are redoing what RustPython (parses python) is doing in order to build their type checker.
After looking at it longer, yep, they forked RustPython. I'm not going to go through the history to find out why, but my first impression is that it's a shame. Now two projects will be doing very similar work, IINM. However, it's about time mypy
had competition. It works fine for many cases, but sometimes just is a very frustrating experience.
IIUC, copying over RustPython parser is an interesting detail, but that change happened earlier (2023!) when they were building Ruff, so it is old news. This piece of code called red-knot seems to be mostly original work, as far as I can tell.
https://github.com/astral-sh/ruff/issues?q=is%3Aopen+label%3Ared-knot+sort%3Acreated-asc
https://xkcd.com/927/ We have PEP for guidance so this doesn't totally apply but...
python already is that comic, to the T. https://chriswarrick.com/blog/2023/01/15/how-to-improve-python-packaging/
There should 1(5), and preferably only 1(5), really obvious way(s) to do it.
Well, Astral as an history of managing to build tools that are actually very very clearly more usable than the pile of poop that Python ecosystem is π
You know, you have me a little hyped then, I've been using pyre but have been looking for a change lol
Nice! This is very exciting. I don't like the current landscape of python type checkers.
Please implement something like pyre-upgrade for being able to enable strict linting and upgrade existing code bases (but without all the other problems pyre brings). https://pyre-check.org/docs/types-in-python/#upgrade
Pyright is very good. The rest are worthless though.
I donβt like the current landscape of python type checkers.
I figure that Python itself is at the bottom of this. It simply wasn't designed for static types. Mypy is still of some use but if you want a statically typed language, trying to graft a type system onto a unityped language hasn't worked out well as far as I know. See also: the Erlang dialyzer, Typed Racket, and whatever that Clojure extension is called. Even Scala has its problems because the JVM has its own type system that isn't that great a fit for Scala.
Also, why Rust as the implementation language? Just for speed? It seems a shame to not use Python/PyPy.
Astral is already a Rust shop; uv
and ruff
are written in Rust, and it makes sense for them to expand on what's already considered very successful.
Rust can enable a lot of speed and "fearless concurrency"; it also has a pretty good type system and a focus on correctness. They'd rather be correct than fast (C made the other choice, but is also from another age), but also show that that extra correctness comes with little runtime speed cost (compilation is another story).
Yes, speed and the benefits of all the tooling and static analysis they're bringing to Python. Python is great for many things but "analyzing Python" isn't necessarily one of them.
I mean, we'll probably disagree on this, but in my not so humble opinion, Python is very unsuited for this large of a project, whereas Rust excels at large projects. I imagine, these folks might have a similar opinion, given that they're building this tool in the first place. π
But execution speed is also not something I'd ignore in a tool like that. I remember having to work with Pipenv and Poetry, and it was just cruel, having to wait more than a minute for it to tell you whether it can resolve dependencies for a fairly small project. And you'll want to run a type checker a lot more often that that.
Is xcancel what I think it is?
I never understood the need for a Python type checker. If I wanted static typing I would code in Fortran.
Just in case that's a genuine question, the reasons people like static types are:
- Catch more bugs.
- Catches bugs earlier (while you are writing the code). This is sometimes called "shift left".
- Fewer tests needed.
- Code is easier to understand.
- Code is easier to navigate.
- Refactoring is much easier.
- Development speed is faster (due to the above points).
Often people say it slows development down but it's actually the opposite. Especially for large projects or ones involving multiple people.
The only downside really is that sometimes the types can get more complicated than they're worth, but in that case you have an escape hatch via the Any
type.
Thanks for the answer. It is a genuine question.
But don't you loose polymorphism? It seems like a big trade-off. For context I'm a scientist doing data analysis and modeling, so my view point is potentially significantly different than most of "the industry".
Your points 1-3 are handled by running the code and reading the error messages, if any. For 4-5 "ugly" code will be unreadable wether it's typed of not. For 6 refactoring now necessitate to change the types everywhere, which I imagine could be error prone and increase code inertia. And for 7 it would definitely slow down developpement untill you get familiar with the libraries and have tooling to automate stuff.
I can understand the appeal for enterprise code but that kind of project seems doomed to go against the Zen of Python anyways, so it's probably not the best language for that.