[python-package] Add specific error codes to all type: ignore comments#12110
Merged
trivialfis merged 5 commits intoMar 20, 2026
Merged
Conversation
Replace all 25 generic `# type: ignore` comments with specific mypy error codes (e.g. `[attr-defined]`, `[union-attr]`, `[assignment]`). This prevents the ignores from silently masking unrelated type errors introduced in future changes. The 3 existing `[no-redef]` annotations in compat.py are unchanged.
PavelGuzenfeld
added a commit
to PavelGuzenfeld/xgboost
that referenced
this pull request
Mar 19, 2026
Corrected error codes based on CI mypy output: - _data_utils.py:378: typeddict-unknown-key -> index - data.py:503: assignment -> name-defined - data.py:981,985: import-untyped -> no-redef - callback.py:442,445: union-attr -> arg-type - spark/core.py:1688,1703: arg-type -> union-attr - testing/updater.py:658: union-attr -> assignment
- _data_utils.py:378: add both [index, typeddict-unknown-key] codes - data.py:981,985: move type: ignore to from-line for multi-line imports
trivialfis
approved these changes
Mar 20, 2026
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.
Summary
Replace all 25 generic
# type: ignorecomments across the Python package with specific mypy error codes. This is a follow-up to #6496.Changes across 10 files:
[union-attr]set()[attr-defined][no-redef][arg-type]mapInPandas()/np.stack(), callbackappend()[assignment]Noneassignment[return-value]_load_lib()returningNonefor doc builds[name-defined]pd.arrays.ArrowExtensionArraynot in stubs[call-overload]@pandas_udfdecorator[index, typeddict-unknown-key]Optional[ArrayInf]Why: Generic
type: ignoresilently masks any type error on that line, including new unrelated errors introduced by future changes. Specific error codes ensure only the known issue is suppressed.No functional changes — only comment annotations.
Test plan