Type Promotion Rules — Python array API standard DRAFT documentation
https://data-apis.org/array-api/draft/API_specification/type_promotion.html

#Python #TypeTheory

Type Promotion Rules — Python array API standard DRAFT documentation

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
NEP 22 — Duck typing for NumPy arrays – high level overview — NumPy Enhancement Proposals