With high-performance #Python type checkers like #Pyright, #Pyrefly, and #ty now available, what's the value proposition of #Mypy? Is it the reference implementation? Or does Mypy still have the most features? I'm not trying to knock Mypy, I'm genuinely asking because I don't know.

I have been investigating this:
```Python
from numbers import Real
def positive(x: Real) -> bool:
return x > 0 # Type Check failed!
```

#PEP 484 said that one should use `float` instead, but this does not solve for other numerical types e.g. #GMP numbers or #NumPy numbers.

And I found some old threads like https://github.com/python/typing/issues/1663
https://github.com/python/mypy/issues/3186
https://discuss.python.org/t/numeric-generics-where-do-we-go-from-pep-3141-and-present-day-mypy/17155
https://discuss.python.org/t/clarifying-the-float-int-complex-special-case/54018/26

And it seems like none has make any real progress.

To my understanding, ABC should also provides a good protocol for typing, just like typeclasses in #Haskell.

#Python #Typing #MyPy #Pyright

Typing spec should be clearer that type checkers are not expected to support PEP 3141 · Issue #1663 · python/typing

With regards to the numeric tower, PEP 484 states: PEP 3141 defines Python’s numeric tower, and the stdlib module numbers implements the corresponding ABCs (Number, Complex, Real, Rational and Inte...

GitHub
🚀🎉 Hold onto your keyboards, folks! #Astral has unleashed "ty," a lightning-fast #Python #type #checker, because, of course, we needed another one. Written in #Rust, because Python apparently wasn't fast enough for checking itself, "ty" is now in #Beta and ready to bravely enter a market already saturated with the likes of #mypy, #Pyright, and other tools you didn't know you couldn't live without. 🌪️🔧
https://astral.sh/blog/ty #ty #HackerNews #ngated
ty: An extremely fast Python type checker and language server

ty is an extremely fast Python type checker and language server, written in Rust, and designed as an alternative to mypy, Pyright, and Pylance.

PyClean v3.4.0 released! Now with Pyright debris removal, cleanup of empty folders only, and git-clean integration to remove untracked files. Try it with #conda or #uv now! `uvx pyclean`. https://pypi.org/project/pyclean/ #python #bytecode #debris #cleanup #development #python3 #cpython #pypy #Linux #macOS #Windows #Pyright #Git
pyclean

Pure Python cross-platform pyclean. Clean up your Python bytecode.

PyPI
All fun and games in #python land until black decides to reformat your #pyright type ignore pragmas 🙄

TIL the overload() decorator for Python, for describing methods that support multiple different combinations of argument types. A great way to make your typechecker happy: it's much stricter and clearer than just combining multiple types with "|".

https://docs.python.org/3/library/typing.html#typing.overload

#python #types #typechecking #pyright

typing — Support for type hints

Source code: Lib/typing.py This module provides runtime support for type hints. Consider the function below: The function surface_area_of_cube takes an argument expected to be an instance of float,...

Python documentation
@feoh Yup. For me its way better than #pyright or #basedpyright.

@seungjin ... #pyright bas the problems of JS : slow....

Python devs are waiting for #ty a rust type checker, built by astral, the ones who did #ruff and #UV

@seungjin I write #python code every day, and type hints are a "syntactic sugar" and are not required at all from the interpreter point of view.

For large projects, it's useful to add hints to "follow" what you are doing, and type checkers like #pyright or #mypy can help to find some bugs, by example when calling a method with wrong parameters types.

It also help for the readability of the code.

Our of the box, #pyright is "better" than #mypy . Less configuration and more strict!