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 errors in plotting.py #4838

Merged
merged 3 commits into from
Dec 2, 2021
Merged

Conversation

jameslamb
Copy link
Collaborator

Contributes to #3867.

This PR fixes mypy errors in plotting.py.

python-package/lightgbm/plotting.py:243: error: Value of type "Union[int, str, None]" is not indexable
python-package/lightgbm/plotting.py:243: error: Unsupported left operand type for - ("str")
python-package/lightgbm/plotting.py:243: note: Both left and right operands are unions
python-package/lightgbm/plotting.py:244: error: Unsupported operand types for / ("str" and "int")
python-package/lightgbm/plotting.py:244: note: Left operand is of type "Union[Any, str]"
python-package/lightgbm/plotting.py:244: error: Value of type "Union[int, str, None]" is not indexable
python-package/lightgbm/plotting.py:256: error: Value of type "Union[int, str, None]" is not indexable
python-package/lightgbm/plotting.py:256: error: Unsupported left operand type for - ("str")
python-package/lightgbm/plotting.py:256: note: Both left and right operands are unions
python-package/lightgbm/plotting.py:257: error: Value of type "Union[int, str, None]" is not indexable
python-package/lightgbm/plotting.py:361: error: Incompatible types in assignment (expression has type "Iterator[Any]", variable has type "Optional[List[str]]")
python-package/lightgbm/plotting.py:365: error: Incompatible types in assignment (expression has type "Iterator[str]", variable has type "Optional[List[str]]")
python-package/lightgbm/plotting.py:367: error: No overload variant of "next" matches argument type "Optional[List[str]]"
python-package/lightgbm/plotting.py:367: note: Possible overload variant:
python-package/lightgbm/plotting.py:367: note: def [_T] next(Iterator[_T]) -> _T
python-package/lightgbm/plotting.py:367: note: <1 more non-matching overload not shown>
python-package/lightgbm/plotting.py:384: error: Item "None" of "Optional[List[str]]" has no attribute "iter" (not iterable)

Confirmed that this suppresses these warnings by running the following.

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

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@StrikerRUS StrikerRUS merged commit f8bab7f into master Dec 2, 2021
@StrikerRUS StrikerRUS deleted the mypy-plotting branch December 2, 2021 01:11
@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