Skip to content
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

WIP: [ci] [python-package] remove unused mypy type-ignore comments #5857

Closed
wants to merge 3 commits into from

Conversation

jameslamb
Copy link
Collaborator

Contributes to #3867.

As more of the library's code gets type annotations, as errors in those annotations are fixed, and as mypy itself is improved, some # type: ignore comments used to suppress mypy errors can become irrelevant.

This PR proposes running mypy with --warn-unused-ignores, which will cause mypy to fail if unnecessary # type: ignore comments are used.

This is useful because # type: ignore comments can sometimes cause mypy to stop checking down a code path, and removing unnecessary ones therefore improves the likelihood that problems can be detected by mypy.

This PR also fixes the following errors introduced by that check.

python-package/lightgbm/basic.py:215: error: Unused "type: ignore" comment
python-package/lightgbm/sklearn.py:1056: error: Unused "type: ignore" comment
python-package/lightgbm/sklearn.py:1057: error: Unused "type: ignore" comment
python-package/lightgbm/sklearn.py:1150: error: Unused "type: ignore" comment
python-package/lightgbm/sklearn.py:1151: error: Unused "type: ignore" comment
python-package/lightgbm/sklearn.py:1212: error: Unused "type: ignore" comment
python-package/lightgbm/sklearn.py:1308: error: Unused "type: ignore" comment
python-package/lightgbm/sklearn.py:1309: error: Unused "type: ignore" comment
python-package/lightgbm/dask.py:1092: error: Unused "type: ignore" comment

@jameslamb jameslamb changed the title [ci] [python-package] remove unused mypy type-ignore comments WIP: [ci] [python-package] remove unused mypy type-ignore comments Apr 26, 2023
@jameslamb
Copy link
Collaborator Author

Going to close this for now to focus on other things. Sorry for the noise.

@jameslamb jameslamb closed this Jun 11, 2023
@jameslamb jameslamb deleted the ci/mypy-unused-comments branch June 11, 2023 04:11
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant