-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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 sklearn.py #4837
Conversation
@@ -1008,7 +1008,7 @@ def fit(self, X, y, | |||
callbacks=callbacks, init_model=init_model) | |||
return self | |||
|
|||
_base_doc = LGBMModel.fit.__doc__.replace("self : LGBMModel", "self : LGBMClassifier") | |||
_base_doc = LGBMModel.fit.__doc__.replace("self : LGBMModel", "self : LGBMClassifier") # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warnings about .__doc__
being Optional[str]
could be avoided by changing this to something like getattr(LGBMModel.fit, "__doc__", "")
, but I think this is preferable, so that .replace()
raises an exception in CI if something is accidentally changed that results in the docs being empty for a method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type hints and #ignore
directives look OK to me, but I disagree with actual code complication for the sake of removing mypy false alarm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks a lot!
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. |
Contributes to #3867.
This PR fixes
mypy
errors insklearn.py
.Confirmed that this suppresses these warnings by running the following.
mypy \ --exclude='python-package/compile/|python-package/build' \ --ignore-missing-imports \ python-package/