Skip to content

🐛 fix failing abstract number binop type-tests #448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion docs/user_guide/differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ And even though it has gotten more verbose, it requires less mental to interpret

## Extended precision removals

The following non-extistent scalar types have been removed (numpy/numtype#209):
The following non-existent scalar types have been removed (numpy/numtype#209):

- `int128` and `int256`
- `uint128` and `uint256`
Expand All @@ -92,6 +92,25 @@ The platform-dependent `float96` and `float128` types are equivalent aliases of
alias `clongdouble` (numpy/numtype#391).
This was done in order to minimize the expected amount of "but it works on my machine".

## Removed `number.__floordiv__`

The abstract `numpy.number` type represents a scalar that's either integer, float, or complex.
But the builtin "floordiv" operator, `//` is only supported for integer and floating scalars.
Complex numpy scalars will raise an error. But in NumPy, type-checkers will allow you to write
the following type-unsafe code:

```py
import numpy as np

def half(a: np.number) -> np.number:
return a // 2

half(np.complex128(1j)) # accepted
```

In NumType's `numpy-stubs`, the `numpy.number.__[r]floordiv__` methods don't exist. This means that
if you have `numtype` installed, your type-checker will report `a // 2` as an error.

## Mypy plugin

NumType does not support the numpy mypy plugin. The reasons for this are explained in the
Expand Down
Loading