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] [dask] fix mypy errors regarding predict_proba #5728

Merged
merged 1 commit into from
Feb 19, 2023
Merged

[python-package] [dask] fix mypy errors regarding predict_proba #5728

merged 1 commit into from
Feb 19, 2023

Conversation

IdoKendo
Copy link
Contributor

Contributes to #3867.
Moved from #5672.

mypy currently raises errors regarding predict_proba() method. This PR proposes a fix for it.

Notes for Reviewers

This was tested by running mypy as documented in #3867.

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

@jameslamb jameslamb changed the title [python-package] fix mypy errors regarding predict_proba [python-package] [dask] fix mypy errors regarding predict_proba Feb 19, 2023
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

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

Excellent, thanks!

I can see that mypy finds 84 errors on the latest commit on master (logs link) and 83 here (logs link).

And that this specifically fixed this one:

python-package/lightgbm/dask.py:1258: error: Signature of "predict_proba" incompatible with supertype "LGBMClassifier"  [override]
python-package/lightgbm/dask.py:1258: note:      Superclass:
python-package/lightgbm/dask.py:1258: note:          def predict_proba(self, X: Any, raw_score: bool = ..., start_iteration: int = ..., num_iteration: Optional[int] = ..., pred_leaf: bool = ..., pred_contrib: bool = ..., validate_features: bool = ..., **kwargs: Any) -> Any
python-package/lightgbm/dask.py:1258: note:      Subclass:
python-package/lightgbm/dask.py:1258: note:          def predict_proba(self, X: Union[Any, Any], **kwargs: Any) -> Any

I also see that this signature matches the argument order and default values for LGBMClassifier.

def predict_proba(
self,
X,
raw_score: bool = False,
start_iteration: int = 0,
num_iteration: Optional[int] = None,
pred_leaf: bool = False,
pred_contrib: bool = False,
validate_features: bool = False,
**kwargs: Any
):

@jameslamb jameslamb merged commit f975d3f into microsoft:master Feb 19, 2023
@IdoKendo IdoKendo deleted the python-package/fix-mypy-predict-proba branch March 9, 2023 15:20
@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 15, 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