Skip to content

[python-package] fix mypy error about pyarrow data#6333

Merged
jameslamb merged 2 commits intomasterfrom
mypy/arrow-types
Feb 21, 2024
Merged

[python-package] fix mypy error about pyarrow data#6333
jameslamb merged 2 commits intomasterfrom
mypy/arrow-types

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 🙄

@jameslamb jameslamb merged commit b60068c into master Feb 21, 2024
@jameslamb jameslamb deleted the mypy/arrow-types branch February 21, 2024 15:18
@jameslamb
Copy link
Collaborator Author

thanks @borchero !

@github-actions
Copy link
Contributor

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 Feb 27, 2025
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