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 for eval_at and basic #5674

Merged
merged 3 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python-package/lightgbm/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,7 @@ def get_field(self, field_name: str) -> Optional[np.ndarray]:

def set_categorical_feature(
self,
categorical_feature: Union[List[int], List[str]]
categorical_feature: Union[List[int], List[str], str]
) -> "Dataset":
"""Set categorical features.

Expand Down Expand Up @@ -2268,7 +2268,7 @@ def set_reference(self, reference: "Dataset") -> "Dataset":
raise LightGBMError("Cannot set reference after freed raw data, "
"set free_raw_data=False when construct Dataset to avoid this.")

def set_feature_name(self, feature_name: List[str]) -> "Dataset":
def set_feature_name(self, feature_name: Union[List[str], str]) -> "Dataset":
"""Set feature name.

Parameters
Expand Down
6 changes: 3 additions & 3 deletions python-package/lightgbm/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def _train(
eval_init_score: Optional[List[_DaskCollection]] = None,
eval_group: Optional[List[_DaskVectorLike]] = None,
eval_metric: Optional[_LGBM_ScikitEvalMetricType] = None,
eval_at: Optional[Union[List[int], Tuple[int]]] = None,
eval_at: Optional[Union[List[int], Tuple[int, ...]]] = None,
**kwargs: Any
) -> LGBMModel:
"""Inner train routine.
Expand Down Expand Up @@ -1045,7 +1045,7 @@ def _lgb_dask_fit(
eval_init_score: Optional[List[_DaskCollection]] = None,
eval_group: Optional[List[_DaskVectorLike]] = None,
eval_metric: Optional[_LGBM_ScikitEvalMetricType] = None,
eval_at: Optional[Iterable[int]] = None,
eval_at: Optional[Union[List[int], Tuple[int, ...]]] = None,
**kwargs: Any
) -> "_DaskLGBMModel":
if not DASK_INSTALLED:
Expand Down Expand Up @@ -1499,7 +1499,7 @@ def fit(
eval_init_score: Optional[List[_DaskVectorLike]] = None,
eval_group: Optional[List[_DaskVectorLike]] = None,
eval_metric: Optional[_LGBM_ScikitEvalMetricType] = None,
eval_at: Union[List[int], Tuple[int]] = (1, 2, 3, 4, 5),
eval_at: Union[List[int], Tuple[int, ...]] = (1, 2, 3, 4, 5),
**kwargs: Any
) -> "DaskLGBMRanker":
"""Docstring is inherited from the lightgbm.LGBMRanker.fit."""
Expand Down
2 changes: 1 addition & 1 deletion python-package/lightgbm/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ def fit(
eval_init_score=None,
eval_group=None,
eval_metric: Optional[_LGBM_ScikitEvalMetricType] = None,
eval_at: Union[List[int], Tuple[int]] = (1, 2, 3, 4, 5),
eval_at: Union[List[int], Tuple[int, ...]] = (1, 2, 3, 4, 5),
feature_name='auto',
categorical_feature='auto',
callbacks=None,
Expand Down