Fix pylint errors. (#7967)

This commit is contained in:
Jiaming Yuan 2022-06-02 18:04:46 +08:00 committed by GitHub
parent 13b15e07e8
commit 6b55150e80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 10 deletions

View File

@ -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,

View File

@ -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.

View File

@ -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
@ -1638,7 +1639,7 @@ class 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.
@ -2370,15 +2371,15 @@ class Booster:
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()
@ -2667,8 +2668,8 @@ class Booster:
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))

View File

@ -1719,7 +1719,7 @@ class DaskScikitLearnBase(XGBModel):
"""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,