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

[python-package] fix mypy error about missing type hint in dask.py #4840

Merged
merged 5 commits into from
Dec 1, 2021

Conversation

jameslamb
Copy link
Collaborator

Contributes to #3867.

This PR fixes one mypy error in dask.py.

python-package/lightgbm/dask.py:933: error: Need type annotation for "out"

Confirmed that this suppresses these warnings by running the following.

mypy \
    --exclude='python-package/compile/|python-package/build' \
    --ignore-missing-imports \
    python-package/

@jmoralez
Copy link
Collaborator

jmoralez commented Dec 1, 2021

I think the first time out is populated in

out[i].append(part)
it's actually List[List[dask_Array]], where each entry has as many items as there are partitions. Then the contents get overwritten in
out[i] = dask_array_from_delayed(
where the partitions get concatenated and the elements become List[dask_Array].

I think variables changing types is a big no-no for mypy so maybe we could define two variables here?

@jameslamb
Copy link
Collaborator Author

it's actuallyList[List[dask_Array]]

ooooooo you're right! I missed that .append(). Fixed in 006a271.

where the partitions get concatenated and the elements become List[dask_Array].
I think variables changing types is a big no-no for mypy so maybe we could define two variables here?

You're generally right about mypy not liking it when code overwrites a variable with a value of a different type than it was initialized with. Fixed in 32f40de.

@jameslamb
Copy link
Collaborator Author

just re-ran the R-package jobs, let's see if the MiKTeX issue (#4005 (comment)) was fixed overnight

@jameslamb
Copy link
Collaborator Author

jameslamb commented Dec 1, 2021

🎉 CI seems happy again!

e.g. from this Windows build

The downloaded binary packages are in
C:\Users\runneradmin\AppData\Local\Temp\RtmpwpHjaj\downloaded_packages
Downloading https://github.com/microsoft/LightGBM/releases/download/v2.0.12/miktexsetup-4.0-x64.zip
Setting up MiKTeX
Installing MiKTeX
Done installing MiKTeX

@jameslamb jameslamb merged commit 8f4126d into master Dec 1, 2021
@jameslamb jameslamb deleted the mypy-dask-out branch December 1, 2021 16:25
@StrikerRUS StrikerRUS mentioned this pull request Jan 6, 2022
13 tasks
@jameslamb jameslamb mentioned this pull request Oct 7, 2022
40 tasks
@github-actions
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 Aug 23, 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.

2 participants