8000 TYP: run mypy in strict mode by jorenham · Pull Request #29097 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

TYP: run mypy in strict mode #29097

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 3 commits into from
May 31, 2025
Merged

TYP: run mypy in strict mode #29097

merged 3 commits into from
May 31, 2025

Conversation

jorenham
Copy link
Member
@jorenham jorenham commented May 30, 2025

"Strict mode" is a combo-package-deal of mypy flags. In mypy --help it explains it as:

Strict mode; enables the following flags: --warn-unused-configs, --disallow-any-generics, --disallow-subclassing-any, --disallow-untyped-calls, --disallow-untyped-defs, --disallow-incomplete-defs, --check-untyped-defs, --disallow-untyped-decorators, --warn-redundant-casts, --warn-unused-ignores, --warn-return-any, --no-implicit-reexport, --strict-equality, --strict-bytes, --extra-checks

This also enables local_partial_types, which will be enabled by default in a future mypy release. See the docs for the details.

And last, but most certainly not least, is allow_redefinition_new. In short, it is a fix for #27957. See the docs for details.

@@ -7,6 +7,8 @@
_ScalarT = TypeVar("_ScalarT", bound=np.generic)
MaskedArray: TypeAlias = np.ma.MaskedArray[_Shape, np.dtype[_ScalarT]]

# mypy: disable-error-code=no-untyped-call
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is required because numpy.ma.core.MaskedArray.__new__ is untyped.

@charris charris merged commit 78f8e06 into numpy:main May 31, 2025
77 checks passed
@charris
Copy link
Member
charris commented May 31, 2025

Thanks Joren.

@jorenham jorenham deleted the typing/mypy-strict branch May 31, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0