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 pyarrow data #6333

Merged
merged 2 commits into from
Feb 21, 2024
Merged

Conversation

jameslamb
Copy link
Collaborator

Contributes to #3756.
Contributes to #3867.

Fixes the following error from mypy:

python-package/lightgbm/basic.py:2889: error: Incompatible types in assignment (expression has type "list[float] | list[int] | ndarray[Any, Any] | Any | Any | Any | Any | None", variable has type "ndarray[Any, dtype[Any]]")  [assignment]

Notes for Reviewers

For more details on how typing.TypeGuard helps with this, see #6106.

Copy link
Collaborator

@borchero borchero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Generally, I don't know why but all of the type checkers I've tried misinterpret types used from pyarrow. For example, pyarrow.Table (and all other types fwiw) is interpreted as Any 🙄

python-package/lightgbm/basic.py Show resolved Hide resolved
@jameslamb jameslamb merged commit b60068c into master Feb 21, 2024
43 checks passed
@jameslamb jameslamb deleted the mypy/arrow-types branch February 21, 2024 15:18
@jameslamb
Copy link
Collaborator Author

thanks @borchero !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants