-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
mypy_arg_type.py
:
import numpy as np
from numpy.typing import NDArray
import random
def winner(_: NDArray[np.bytes_]) -> bytes | None:
return b"." if bool(random.randint(0, 1)) else None
board = np.full((2, 2), ".", "|S1")
for w in np.apply_along_axis(winner, 0, board):
print(w)
>> python mypy_arg_type.py
b'.'
None
>> mypy mypy_arg_type.py
mypy_arg_type.py:9: error: Argument 1 to "apply_along_axis" has incompatible type "Callable[[ndarray[Any, dtype[bytes_]]], bytes | None]"; expected "Callable[[ndarray[Any, dtype[Any]]], _SupportsArray[dtype[Never]] | _NestedSequence[_SupportsArray[dtype[Never]]]]" [arg-type]
mypy_arg_type.py:9: note: This is likely because "winner" has named arguments: "_". Consider marking them positional-only
Found 1 error in 1 file (checked 1 source file)
Expected Behavior
No violations.
Actual Behavior
Shown above. Making function winner
positional-only makes no difference, except that suggestion is gone.
Your Environment
- Mypy version used: 1.11.2
- Mypy command-line flags:
--strict
- Mypy configuration options from
mypy.ini
(and other config files):
[tool.mypy]
exclude = [
'venv'
]
- Python version used: 3.12.5
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong