Skip to content

Commit

Permalink
[backport] Fix pylint errors. (#7967) (#7981)
Browse files Browse the repository at this point in the history
* Fix pylint errors. (#7967)

* Rebase error.
  • Loading branch information
trivialfis authored Jun 7, 2022
1 parent 5973c6e commit a55d3bd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion python-package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 @@ -1577,7 +1578,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 @@ -2309,15 +2310,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 @@ -2604,8 +2605,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
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,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
1 change: 0 additions & 1 deletion python-package/xgboost/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# pylint: disable=too-many-return-statements, import-error
'''Data dispatching for DMatrix.'''
import ctypes
from distutils import version
import json
import warnings
import os
Expand Down

0 comments on commit a55d3bd

Please sign in to comment.