Skip to content

Commit

Permalink
[python-package] fix mypy errors in sklearn.py (#4837)
Browse files Browse the repository at this point in the history
* [python-package] fix mypy errors in sklearn.py

* use ignore comments
  • Loading branch information
jameslamb authored Dec 2, 2021
1 parent f57ef6f commit e048a6b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions python-package/lightgbm/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np

from .basic import Dataset, LightGBMError, _ArrayLike, _choose_param_value, _ConfigAliases, _log_warning
from .basic import Booster, Dataset, LightGBMError, _ArrayLike, _choose_param_value, _ConfigAliases, _log_warning
from .callback import log_evaluation, record_evaluation
from .compat import (SKLEARN_INSTALLED, LGBMNotFittedError, _LGBMAssertAllFinite, _LGBMCheckArray,
_LGBMCheckClassificationTargets, _LGBMCheckSampleWeight, _LGBMCheckXY, _LGBMClassifierBase,
Expand Down Expand Up @@ -514,11 +514,11 @@ def __init__(
self.random_state = random_state
self.n_jobs = n_jobs
self.importance_type = importance_type
self._Booster = None
self._Booster: Optional[Booster] = None
self._evals_result = None
self._best_score = None
self._best_iteration = None
self._other_params = {}
self._other_params: Dict[str, Any] = {}
self._objective = objective
self.class_weight = class_weight
self._class_weight = None
Expand Down Expand Up @@ -893,7 +893,7 @@ def n_estimators_(self) -> int:
"""
if not self.__sklearn_is_fitted__():
raise LGBMNotFittedError('No n_estimators found. Need to call fit beforehand.')
return self._Booster.current_iteration()
return self._Booster.current_iteration() # type: ignore

@property
def n_iter_(self) -> int:
Expand All @@ -904,7 +904,7 @@ def n_iter_(self) -> int:
"""
if not self.__sklearn_is_fitted__():
raise LGBMNotFittedError('No n_iter found. Need to call fit beforehand.')
return self._Booster.current_iteration()
return self._Booster.current_iteration() # type: ignore

@property
def booster_(self):
Expand Down Expand Up @@ -958,7 +958,7 @@ def fit(self, X, y,
categorical_feature=categorical_feature, callbacks=callbacks, init_model=init_model)
return self

_base_doc = LGBMModel.fit.__doc__.replace("self : LGBMModel", "self : LGBMRegressor")
_base_doc = LGBMModel.fit.__doc__.replace("self : LGBMModel", "self : LGBMRegressor") # type: ignore
_base_doc = (_base_doc[:_base_doc.find('group :')] # type: ignore
+ _base_doc[_base_doc.find('eval_set :'):]) # type: ignore
_base_doc = (_base_doc[:_base_doc.find('eval_class_weight :')]
Expand Down Expand Up @@ -1025,7 +1025,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
_base_doc = (_base_doc[:_base_doc.find('group :')] # type: ignore
+ _base_doc[_base_doc.find('eval_set :'):]) # type: ignore
fit.__doc__ = (_base_doc[:_base_doc.find('eval_group :')]
Expand Down Expand Up @@ -1124,7 +1124,7 @@ def fit(self, X, y,
categorical_feature=categorical_feature, callbacks=callbacks, init_model=init_model)
return self

_base_doc = LGBMModel.fit.__doc__.replace("self : LGBMModel", "self : LGBMRanker")
_base_doc = LGBMModel.fit.__doc__.replace("self : LGBMModel", "self : LGBMRanker") # type: ignore
fit.__doc__ = (_base_doc[:_base_doc.find('eval_class_weight :')] # type: ignore
+ _base_doc[_base_doc.find('eval_init_score :'):]) # type: ignore
_base_doc = fit.__doc__
Expand Down

0 comments on commit e048a6b

Please sign in to comment.