Skip to content

Commit

Permalink
Fix pylint errors. (#7967)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Jun 2, 2022
1 parent 13b15e0 commit 6b55150
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion python-package/setup.py
Expand Up @@ -96,7 +96,7 @@ class BuildExt(build_ext.build_ext): # pylint: disable=too-many-ancestors

logger = logging.getLogger('XGBoost build_ext')

# pylint: disable=too-many-arguments,no-self-use
# pylint: disable=too-many-arguments
def build(
self,
src_dir: str,
Expand Down
2 changes: 1 addition & 1 deletion python-package/xgboost/callback.py
@@ -1,5 +1,5 @@
# coding: utf-8
# pylint: disable=invalid-name, too-many-statements, no-self-use
# pylint: disable=invalid-name, too-many-statements
# pylint: disable=too-many-arguments
"""Callback library containing training routines. See :doc:`Callback Functions
</python/callbacks>` for a quick introduction.
Expand Down
15 changes: 8 additions & 7 deletions python-package/xgboost/core.py
Expand Up @@ -3,6 +3,7 @@
"""Core XGBoost Library."""
from abc import ABC, abstractmethod
from collections.abc import Mapping
import copy
from typing import List, Optional, Any, Union, Dict, TypeVar
from typing import Callable, Tuple, cast, Sequence, Type, Iterable
import ctypes
Expand Down Expand Up @@ -1638,7 +1639,7 @@ def copy(self) -> "Booster":
booster: `Booster`
a copied booster model
"""
return self.__copy__()
return copy.copy(self)

def attr(self, key: str) -> Optional[str]:
"""Get attribute string from the Booster.
Expand Down Expand Up @@ -2370,15 +2371,15 @@ def dump_model(self, fout: Union[str, os.PathLike], fmap: Union[str, os.PathLike
ret = self.get_dump(fmap, with_stats, dump_format)
if dump_format == 'json':
fout_obj.write('[\n')
for i, _ in enumerate(ret):
fout_obj.write(ret[i])
for i, val in enumerate(ret):
fout_obj.write(val)
if i < len(ret) - 1:
fout_obj.write(",\n")
fout_obj.write('\n]')
else:
for i, _ in enumerate(ret):
for i, val in enumerate(ret):
fout_obj.write(f"booster[{i}]:\n")
fout_obj.write(ret[i])
fout_obj.write(val)
if need_close:
fout_obj.close()

Expand Down Expand Up @@ -2667,8 +2668,8 @@ def get_split_value_histogram(
values = []
# pylint: disable=consider-using-f-string
regexp = re.compile(r"\[{0}<([\d.Ee+-]+)\]".format(feature))
for i, _ in enumerate(xgdump):
m = re.findall(regexp, xgdump[i])
for i, val in enumerate(xgdump):
m = re.findall(regexp, val)
values.extend([float(x) for x in m])

n_unique = len(np.unique(values))
Expand Down
2 changes: 1 addition & 1 deletion python-package/xgboost/dask.py
Expand Up @@ -1719,7 +1719,7 @@ def _client_sync(self, func: Callable, **kwargs: Any) -> Any:
"""Implementation of the Scikit-Learn API for XGBoost.""", ["estimators", "model"]
)
class DaskXGBRegressor(DaskScikitLearnBase, XGBRegressorBase):
# pylint: disable=missing-class-docstring
"""dummy doc string to workaround pylint, replaced by the decorator."""
async def _fit_async(
self,
X: _DaskCollection,
Expand Down

0 comments on commit 6b55150

Please sign in to comment.