[dask] fix typehint on _pad_eval_names() #4413
Merged
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.
Following up on #4101 (review) (cc @ffineis just so you know this is what I was talking about in that comment).
The function
lightgbm.dask._pad_eval_names()
currently has a type hint suggesting that argumentrequired_names
could beNone
, but its code doesn't handle that case. Thefor
loop below would fail with an error complaining aboutNoneType
not being iterable.LightGBM/python-package/lightgbm/dask.py
Line 98 in b5502d1
I don't think it is actually possible for that argument to ever be
None
, because ofLightGBM/python-package/lightgbm/dask.py
Lines 186 to 189 in b5502d1
LightGBM/python-package/lightgbm/dask.py
Line 279 in b5502d1
This PR proposes updating the type hint.
Notes for Reviewers
Noting that in the future, this is the type of thing that will be caught by
mypy
(#3867). Runningmypy --ignore-missing-import python-package/lightgbm
yields the following.