-
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 about missing annotations and incompatible types #5672
Changes from 6 commits
e228ff2
f9390f2
18f35d0
d8f15bb
222a92e
5487ca5
4c76974
6a1c593
e079742
c94ccb5
4cb3474
9ac356b
5fab4fb
f773330
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1174,7 +1174,7 @@ def fit( # type: ignore[override] | |
eval_init_score: Optional[List[_DaskCollection]] = None, | ||
eval_metric: Optional[_LGBM_ScikitEvalMetricType] = None, | ||
**kwargs: Any | ||
) -> "DaskLGBMClassifier": | ||
) -> "_DaskLGBMModel": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is the right fix. I'd expect But I understand why Instead of changing the return type hints, can you please try changing the body of these def fit(...) -> "DaskLGBMClassifier":
self._lgb_dask_fit(...)
return self And see if:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed you've removed these Dask changes from this PR and they aren't included in the other mypy-related PR you opened (#5731). Are you interested in trying them out? If not, I'll fix these issues related to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not. No worries, I'll attempt this particlar fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created #5756. To add more details on why the presence of The The errors about return types are saying "hey you told me that this
|
||
"""Docstring is inherited from the lightgbm.LGBMClassifier.fit.""" | ||
return self._lgb_dask_fit( | ||
model_factory=LGBMClassifier, | ||
|
@@ -1256,13 +1256,29 @@ def predict( | |
X_SHAP_values_shape="Dask Array of shape = [n_samples, n_features + 1] or shape = [n_samples, (n_features + 1) * n_classes] or (if multi-class and using sparse inputs) a list of ``n_classes`` Dask Arrays of shape = [n_samples, n_features + 1]" | ||
) | ||
|
||
def predict_proba(self, X: _DaskMatrixLike, **kwargs: Any) -> dask_Array: | ||
def predict_proba( | ||
jameslamb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self, | ||
X: _DaskMatrixLike, | ||
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 | ||
) -> dask_Array: | ||
"""Docstring is inherited from the lightgbm.LGBMClassifier.predict_proba.""" | ||
return _predict( | ||
model=self.to_local(), | ||
data=X, | ||
pred_proba=True, | ||
client=_get_dask_client(self.client), | ||
raw_score=raw_score, | ||
start_iteration=start_iteration, | ||
num_iteration=num_iteration, | ||
pred_leaf=pred_leaf, | ||
pred_contrib=pred_contrib, | ||
validate_features=validate_features, | ||
**kwargs | ||
) | ||
|
||
|
@@ -1361,7 +1377,7 @@ def fit( # type: ignore[override] | |
eval_init_score: Optional[List[_DaskVectorLike]] = None, | ||
eval_metric: Optional[_LGBM_ScikitEvalMetricType] = None, | ||
**kwargs: Any | ||
) -> "DaskLGBMRegressor": | ||
) -> "_DaskLGBMModel": | ||
"""Docstring is inherited from the lightgbm.LGBMRegressor.fit.""" | ||
return self._lgb_dask_fit( | ||
model_factory=LGBMRegressor, | ||
|
@@ -1533,7 +1549,7 @@ def fit( # type: ignore[override] | |
eval_metric: Optional[_LGBM_ScikitEvalMetricType] = None, | ||
eval_at: Union[List[int], Tuple[int, ...]] = (1, 2, 3, 4, 5), | ||
**kwargs: Any | ||
) -> "DaskLGBMRanker": | ||
) -> "_DaskLGBMModel": | ||
"""Docstring is inherited from the lightgbm.LGBMRanker.fit.""" | ||
return self._lgb_dask_fit( | ||
model_factory=LGBMRanker, | ||
|
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.
Please don't include
None
in this type hint. That makes it difficult to use in other parts of the code whereNone
isn't a valid value.