diff --git a/python-package/xgboost/core.py b/python-package/xgboost/core.py index 015988f9a..0514f0c27 100644 --- a/python-package/xgboost/core.py +++ b/python-package/xgboost/core.py @@ -1119,7 +1119,9 @@ class DeviceQuantileDMatrix(DMatrix): ctypes.byref(handle), ) if it.exception is not None: - raise it.exception + # pylint 2.7.0 believes `it.exception` can be None even with `assert + # isinstace` + raise it.exception # pylint: disable=raising-bad-type # delay check_call to throw intermediate exception first _check_call(ret) self.handle = handle @@ -1315,7 +1317,7 @@ class Booster(object): self.handle, ctypes.byref(length), ctypes.byref(json_string))) - json_string = json_string.value.decode() # NOLINT + json_string = json_string.value.decode() # pylint: disable=no-member return json_string def load_config(self, config): @@ -1508,7 +1510,7 @@ class Booster(object): dmats, evnames, c_bst_ulong(len(evals)), ctypes.byref(msg))) - res = msg.value.decode() # NOLINT + res = msg.value.decode() # pylint: disable=no-member if feval is not None: for dmat, evname in evals: feval_ret = feval(self.predict(dmat, training=False, diff --git a/python-package/xgboost/dask.py b/python-package/xgboost/dask.py index 5d32d46bc..26bec393f 100644 --- a/python-package/xgboost/dask.py +++ b/python-package/xgboost/dask.py @@ -712,7 +712,7 @@ def _create_dmatrix( T = TypeVar('T') def concat_or_none(data: Tuple[Optional[T], ...]) -> Optional[T]: - if any([part is None for part in data]): + if any(part is None for part in data): return None return concat(data) diff --git a/python-package/xgboost/sklearn.py b/python-package/xgboost/sklearn.py index f0589cd2e..f9b32e068 100644 --- a/python-package/xgboost/sklearn.py +++ b/python-package/xgboost/sklearn.py @@ -293,14 +293,12 @@ def _wrap_evaluation_matrices( evals = list(zip(evals, eval_names)) else: if any( - [ - meta is not None - for meta in [ - sample_weight_eval_set, - base_margin_eval_set, - eval_group, - eval_qid, - ] + meta is not None + for meta in [ + sample_weight_eval_set, + base_margin_eval_set, + eval_group, + eval_qid, ] ): raise ValueError(