We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
Bug Report
Slice using colon notation has different behavior from slice using built-in slice function.
To Reproduce
Use colon notation will have error message.
import numpy as onp import numpy.typing as onpt imin: onpt.NDArray[onp.int64] = onp.array(0) imax: onpt.NDArray[onp.int64] = onp.array(2) M = onp.array([1.0, 2.0, 3.0, 4.0]) print(M[imin:imax])
error: Slice index must be an integer or None [misc] Found 1 error in 1 file (checked 1 source file)
But using built-in slice function has no problem.
import numpy as onp import numpy.typing as onpt imin: onpt.NDArray[onp.int64] = onp.array(0) imax: onpt.NDArray[onp.int64] = onp.array(2) M = onp.array([1.0, 2.0, 3.0, 4.0]) islice = slice(imin, imax) print(M[islice])
Success: no issues found in 1 source file
Expected Behavior
Colon slice should has no error message as built-in slice function.
Actual Behavior
Colon slice has error message which is unexpected.
Your Environment
mypy.ini
[tool.mypy] plugins = "numpy.typing.mypy_plugin" check_untyped_defs = true disallow_any_generics = true ignore_missing_imports = true no_implicit_optional = true show_error_codes = true strict_equality = true warn_redundant_casts = true warn_return_any = true warn_unreachable = true warn_unused_configs = true no_implicit_reexport = false
The text was updated successfully, but these errors were encountered:
CC @Zac-HD
It might be related to the recent feature you were interested in 🙂
Sorry, something went wrong.
Nope, not related - my PR was type-level slicing, this is value-level.
It looks like this bug has been fixed. I'm not able to repro the error using mypy 1.5.
I fixed this in #14738
No branches or pull requests
Bug Report
Slice using colon notation has different behavior from slice using built-in slice function.
To Reproduce
Use colon notation will have error message.
But using built-in slice function has no problem.
Expected Behavior
Colon slice should has no error message as built-in slice function.
Actual Behavior
Colon slice has error message which is unexpected.
Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: