Repository navigation
Do not report operand notes when the error they explain is ignored - #22281
Closed
Dextheking1 wants to merge 5 commits into
Closed
Dextheking1 wants to merge 5 commits into
Dextheking1 wants to merge 5 commits into
Conversation
Dextheking1
marked this pull request as ready for review
October 23, 2026 02:15
for more information, see https://pre-commit.ci
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: colour (https://github.com/colour-science/colour)
- colour/utilities/array.py:4405: note: Right operand is of type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]"
- colour/utilities/array.py:4751: note: Right operand is of type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]"
cvxpy (https://github.com/cvxpy/cvxpy)
- cvxpy/lin_ops/backends/base.py:356: note: Both left and right operands are unions
freqtrade (https://github.com/freqtrade/freqtrade)
- freqtrade/data/converter/orderflow.py:172: note: Both left and right operands are unions
- freqtrade/strategy/strategy_helper.py:105: note: Left operand is of type "str | bytes | date | timedelta | datetime64[Any] | <7 more items>"
- freqtrade/strategy/strategy_helper.py:106: note: Left operand is of type "str | bytes | date | timedelta | datetime64[Any] | <7 more items>"
- freqtrade/data/btanalysis/trade_parallelism.py:151: note: Right operand is of type "int | Any | datetime64[Any] | timedelta64[Any] | float | complex | floating[Any] | complexfloating[Any, Any]"
- freqtrade/data/btanalysis/trade_parallelism.py:151: note: Right operand is of type "str | bytes | date | datetime | timedelta | <7 more items> | complex | integer[Any] | floating[Any] | complexfloating[Any, Any]"
- freqtrade/data/btanalysis/trade_parallelism.py:156: note: Right operand is of type "int | Any | datetime64[Any] | timedelta64[Any] | float | complex | floating[Any] | complexfloating[Any, Any]"
- freqtrade/data/btanalysis/trade_parallelism.py:156: note: Left operand is of type "str | bytes | date | datetime | timedelta | <7 more items> | complex | integer[Any] | floating[Any] | complexfloating[Any, Any]"
- freqtrade/util/migrations/migrate_wallet_history.py:153: note: Left operand is of type "int | slice[Any, Any, Any] | ndarray[tuple[int], dtype[numpy.bool[builtins.bool]]]"
- freqtrade/optimize/analysis/lookahead.py:83: note: Left operand is of type "int | slice[Any, Any, Any] | ndarray[tuple[int], dtype[numpy.bool[builtins.bool]]]"
jax (https://github.com/google/jax)
- jax/_src/pallas/mosaic/lowering.py:2174: note: Left operand is of type "int | Squeezed"
sphinx (https://github.com/sphinx-doc/sphinx)
- sphinx/testing/util.py:80:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
scipy-stubs (https://github.com/scipy/scipy-stubs)
- tests/misc/test_submodules_empty.pyi:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The "Right operand is of type ..." note for a binary operation was reported with code
operator, even when the error it explains had a different code. For the case in the issue, the error isarg-type, sox <= y # type: ignore[arg-type]suppressed the error but the note still showed, plus a bogusError code "operator" not covered by "type: ignore[arg-type]" commentnote. Expected output is none.Fix: check_op now passes the filtered error as parent_error for the operand union notes, so the note takes the parent error code and is suppressed together with it. add_error_info also no longer generates "not covered" notes for notes, only for errors.
Test: added testIgnoreOperatorNoteWithDifferentErrorCode to check-ignore.test, with --warn-unused-ignores and no expected output. It passes. Also ran the check-classes, check-callable, check-enum, check-isinstance, check-errorcodes and check-flags data-driven subsets, they pass (1327 passed, apart from testErrorCodeTypeIgnoreMisspelled2 which fails the same way on a clean master checkout here).
Fixes #22230