remove more pylint suppression comments (#10084)

This commit is contained in:
skshetry
2023-11-10 15:19:52 +05:45
committed by GitHub
parent 519cce3fe4
commit d678773b53
47 changed files with 53 additions and 76 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
# ruff: noqa: N999
from PyInstaller.utils.hooks import copy_metadata # pylint:disable=import-error
from PyInstaller.utils.hooks import copy_metadata
# needed for `dvc doctor` to show dep versions
datas = copy_metadata("adlfs", recursive=True)
+1 -1
View File
@@ -1,4 +1,4 @@
# ruff: noqa: N999
from PyInstaller.utils.hooks import copy_metadata # pylint:disable=import-error
from PyInstaller.utils.hooks import copy_metadata
datas = copy_metadata("flatten-dict")
+1 -1
View File
@@ -1,4 +1,4 @@
# ruff: noqa: N999
from PyInstaller.utils.hooks import copy_metadata # pylint:disable=import-error
from PyInstaller.utils.hooks import copy_metadata
datas = copy_metadata("pydrive2")
+3 -3
View File
@@ -65,9 +65,9 @@ def yappi_profile(
else:
if ctx_id is not None:
print(f"\nThread {ctx_id}") # noqa: T201
st.print_all() # pylint:disable=no-member
st.print_all()
if ctx_id is None:
threads.print_all() # pylint:disable=no-member
threads.print_all()
yappi.clear_stats()
@@ -117,7 +117,7 @@ def debug():
yield
except Exception:
try:
import ipdb as pdb # noqa: T100, pylint: disable=import-error
import ipdb as pdb # noqa: T100
except ImportError:
import pdb # type: ignore[no-redef] # noqa: T100
pdb.post_mortem()
+1 -1
View File
@@ -67,7 +67,7 @@ class _OpenContextManager(GCM):
raise AttributeError("dvc.api.open() should be used in a with statement.")
def open( # noqa: A001, pylint: disable=redefined-builtin
def open( # noqa: A001
path: str,
repo: Optional[str] = None,
rev: Optional[str] = None,
-1
View File
@@ -2,7 +2,6 @@ from typing import Optional
try:
# file is created during dvc build
# pylint:disable=unused-import
from . import _build # type: ignore[attr-defined, import]
PKG: Optional[str] = _build.PKG # type: ignore[assignment]
+1 -1
View File
@@ -229,7 +229,7 @@ def main(argv=None): # noqa: C901, PLR0912, PLR0915
logger.exception("")
except DvcParserError:
ret = 254
except Exception as exc: # noqa: BLE001, pylint: disable=broad-except
except Exception as exc: # noqa: BLE001
ret = _log_exceptions(exc) or 255
try:
-2
View File
@@ -71,7 +71,6 @@ def _fork_process() -> int:
# with PyInstaller has trouble with SystemExit exception and throws
# errors such as "[26338] Failed to execute script __main__"
try:
# pylint: disable-next=no-member
pid = os.fork() # type: ignore[attr-defined]
if pid > 0:
return pid
@@ -82,7 +81,6 @@ def _fork_process() -> int:
os.setsid() # type: ignore[attr-defined]
try:
# pylint: disable-next=no-member
pid = os.fork() # type: ignore[attr-defined]
if pid > 0:
os._exit(0)
-2
View File
@@ -166,7 +166,6 @@ class FileMixin:
**kwargs,
)
# pylint: disable-next=unused-argument
def remove(self, force=False): # noqa: ARG002
with contextlib.suppress(FileNotFoundError):
os.unlink(self.path)
@@ -208,7 +207,6 @@ class SingleStageFile(FileMixin):
dump_yaml(self.path, serialize.to_single_stage_file(stage, **kwargs))
self.repo.scm_context.track_file(self.relpath)
# pylint: disable-next=unused-argument
def remove_stage(self, stage): # noqa: ARG002
self.remove()
+1 -1
View File
@@ -301,7 +301,7 @@ class URLMissingError(DvcException):
super().__init__(f"The path '{url}' does not exist")
class IsADirectoryError(DvcException): # noqa: A001,pylint:disable=redefined-builtin
class IsADirectoryError(DvcException): # noqa: A001
"""Raised when a file operation is requested on a directory."""
+2 -5
View File
@@ -44,9 +44,6 @@ known_implementations.update(
)
# pylint: enable=unused-import
def download(
fs: "FileSystem", fs_path: str, to: str, jobs: Optional[int] = None
) -> int:
@@ -164,8 +161,8 @@ def get_cloud_fs(repo_config, **kwargs):
# should be treated as being a root path.
fs_path = cls.root_marker
else:
fs_path = cls._strip_protocol(url) # pylint:disable=protected-access
fs_path = cls._strip_protocol(url)
extras = cls._get_kwargs_from_urls(url) # pylint:disable=protected-access
extras = cls._get_kwargs_from_urls(url)
conf = {**extras, **remote_conf} # remote config takes priority
return cls, conf, fs_path
+1 -1
View File
@@ -71,7 +71,7 @@ class RichCallback(Callback):
value: int = 0,
progress: Optional["RichTransferProgress"] = None,
desc: Optional[str] = None,
bytes: bool = False, # noqa: A002, pylint: disable=redefined-builtin
bytes: bool = False, # noqa: A002
unit: Optional[str] = None,
disable: bool = False,
transient: bool = True,
+1 -1
View File
@@ -10,7 +10,7 @@ if TYPE_CHECKING:
from dvc.scm import Git
class GitFileSystem(FileSystem): # pylint:disable=abstract-method
class GitFileSystem(FileSystem):
"""Proxies the repo file access methods to Git objects"""
protocol = "local"
+1 -2
View File
@@ -149,7 +149,6 @@ class LoggerHandler(logging.StreamHandler):
self.emit_pretty_exception(exc, verbose=_is_verbose())
if not _is_verbose():
return
# pylint: disable-next=broad-except
except Exception: # noqa: BLE001, S110
pass
@@ -158,7 +157,7 @@ class LoggerHandler(logging.StreamHandler):
self.flush()
except (BrokenPipeError, RecursionError):
raise
except Exception: # noqa: BLE001, pylint: disable=broad-except
except Exception: # noqa: BLE001
self.handleError(record)
+1 -3
View File
@@ -331,7 +331,7 @@ class Output:
plot=False,
persist=False,
desc=None,
type=None, # noqa: A002, pylint: disable=redefined-builtin
type=None, # noqa: A002
labels=None,
meta=None,
remote=None,
@@ -694,8 +694,6 @@ class Output:
self.repo.scm_context.ignore_remove(self.fspath)
# pylint: enable=no-member
def save(self) -> None:
if self.use_cache and not self.is_in_repo:
raise DvcException(
+2 -2
View File
@@ -82,12 +82,12 @@ def escape_str(value):
@singledispatch
def to_str(obj, config=None) -> str: # noqa: ARG001, pylint: disable=unused-argument
def to_str(obj, config=None) -> str: # noqa: ARG001
return str(obj)
@to_str.register(bool)
def _(obj: bool, config=None): # noqa: ARG001, pylint: disable=unused-argument
def _(obj: bool, config=None): # noqa: ARG001
return "true" if obj else "false"
+1 -1
View File
@@ -48,7 +48,7 @@ class Tqdm(tqdm):
desc=None,
leave=False,
bar_format=None,
bytes=False, # noqa: A002, pylint: disable=redefined-builtin
bytes=False, # noqa: A002
file=None,
total=None,
postfix=None,
+1 -1
View File
@@ -109,7 +109,7 @@ def match_defs_renderers( # noqa: C901, PLR0912
try:
dps, rev_props = converter.flat_datapoints(rev)
except Exception as e: # noqa: BLE001, pylint: disable=broad-except
except Exception as e: # noqa: BLE001
logger.warning("In %r, %s", rev, str(e).lower())
def_errors[rev] = e
continue
-2
View File
@@ -386,9 +386,7 @@ class Repo:
if self.subrepos:
fs_path = self.dvcfs.from_os_path(path)
fs = self.dvcfs.fs
# pylint: disable-next=protected-access
key = fs._get_key_from_relative(fs_path)
# pylint: disable-next=protected-access
subrepo, _, key = fs._get_subrepo_info(key)
index = subrepo.index.data[workspace]
else:
+4 -4
View File
@@ -238,7 +238,7 @@ class Artifacts:
from_infos.append(url)
except DvcException:
raise
except Exception as exc: # noqa: BLE001, pylint: disable=broad-except
except Exception as exc: # noqa: BLE001
raise DvcException(
f"Failed to download artifact '{name}' via Studio"
) from exc
@@ -298,7 +298,7 @@ class Artifacts:
)
except FileExistsLocallyError:
raise
except Exception as exc: # noqa: BLE001, pylint: disable=broad-except
except Exception as exc: # noqa: BLE001
saved_exc = exc
if config and not isinstance(config, dict):
@@ -326,7 +326,7 @@ class Artifacts:
)
except FileExistsLocallyError:
raise
except Exception as exc: # noqa: BLE001, pylint: disable=broad-except
except Exception as exc: # noqa: BLE001
saved_exc = exc
try:
@@ -340,7 +340,7 @@ class Artifacts:
)
except FileExistsLocallyError:
raise
except Exception as exc: # noqa: BLE001, pylint: disable=broad-except
except Exception as exc: # noqa: BLE001
if saved_exc:
logger.exception(str(saved_exc), exc_info=saved_exc.__cause__)
raise DvcException(
-1
View File
@@ -92,7 +92,6 @@ def commit_2_to_3(repo: "Repo", dry: bool = False):
for out in view.outs:
dvcfile = out.stage.dvcfile.relpath
if isinstance(out.stage.dvcfile, ProjectFile):
# pylint: disable-next=protected-access
lockfile = out.stage.dvcfile._lockfile.relpath
migrated.add(f"{dvcfile} ({lockfile})")
else:
-1
View File
@@ -135,7 +135,6 @@ def diff(
continue
def onerror(target, _exc):
# pylint: disable-next=cell-var-from-loop
missing_targets[rev].add(target) # noqa: B023
view = self.index.targets_view(
+1 -1
View File
@@ -73,7 +73,7 @@ def collect_rev(
if not (rev == "workspace" or param_deps or data.contains_error):
cache.put(data, force=True)
return ExpState(rev=rev, data=data)
except Exception as exc: # noqa: BLE001, pylint: disable=broad-except
except Exception as exc: # noqa: BLE001
logger.debug("", exc_info=True)
error = SerializableError(str(exc), type(exc).__name__)
return ExpState(rev=rev, error=error)
+1 -1
View File
@@ -687,7 +687,7 @@ class BaseExecutor(ABC):
push_cache=push_cache,
run_cache=run_cache,
)
except BaseException as exc: # noqa: BLE001, pylint: disable=W0703
except BaseException as exc: # noqa: BLE001
logger.warning(
(
"Something went wrong while auto pushing experiment "
+1 -1
View File
@@ -133,7 +133,7 @@ def push(
if push_cache:
try:
result["uploaded"] = _push_cache(repo, pushed_refs_info, **kwargs)
except Exception as exc: # noqa: BLE001, pylint: disable=broad-except
except Exception as exc: # noqa: BLE001
e = exc
pushed_refs = [str(r) for r in pushed_refs_info]
+1 -1
View File
@@ -441,7 +441,7 @@ class BaseStashQueue(ABC):
with open(self.args_file, "rb") as fobj:
try:
data = pickle.load(fobj) # noqa: S301
except Exception: # noqa: BLE001, pylint: disable=broad-except
except Exception: # noqa: BLE001
data = {}
extra = int(data.get("extra", 0)) + 1
else:
+1 -1
View File
@@ -44,7 +44,7 @@ def setup_exp(entry_dict: Dict[str, Any]) -> "BaseExecutor":
@shared_task
def collect_exp(
proc_dict: Dict[str, Any], # noqa: ARG001, pylint: disable=unused-argument
proc_dict: Dict[str, Any], # noqa: ARG001
entry_dict: Dict[str, Any],
) -> str:
"""Collect results for an experiment.
+1 -1
View File
@@ -304,7 +304,7 @@ class Index:
def check_graph(self) -> None:
if not getattr(self.repo, "_skip_graph_checks", False):
self.graph # noqa: B018, pylint: disable=pointless-statement
self.graph # noqa: B018
@property
def params(self) -> Iterator["ParamsDependency"]:
+2 -2
View File
@@ -76,7 +76,7 @@ def _read_metrics(
for metric in metrics:
try:
yield metric, _read_metric(fs, metric, **load_kwargs)
except Exception as exc: # noqa: BLE001 # pylint:disable=broad-exception-caught
except Exception as exc: # noqa: BLE001
logger.debug(exc)
yield metric, exc
@@ -219,7 +219,7 @@ def show(
on_error=on_error,
)
res[rev] = Result(data=result)
except Exception as exc: # noqa: BLE001 # pylint:disable=broad-exception-caught
except Exception as exc: # noqa: BLE001
if on_error == "raise":
raise
+2 -2
View File
@@ -108,7 +108,7 @@ def _read_params(
for file_path, key_paths in params.items():
try:
yield file_path, read_param_file(fs, file_path, key_paths, **load_kwargs)
except Exception as exc: # noqa: BLE001 # pylint:disable=broad-exception-caught
except Exception as exc: # noqa: BLE001
logger.debug(exc)
yield file_path, exc
@@ -192,7 +192,7 @@ def show(
on_error=on_error,
)
res[rev] = Result(data=params)
except Exception as exc: # noqa: BLE001 # pylint:disable=broad-exception-caught
except Exception as exc: # noqa: BLE001
if on_error == "raise":
raise
logger.warning("failed to load params in revision %r, %s", rev, str(exc))
+1 -1
View File
@@ -197,7 +197,7 @@ def _reproduce(
try:
ret = repro_fn(stage, upstream=upstream, force=force_stage, **kwargs)
except Exception as exc: # noqa: BLE001, pylint: disable=broad-exception-caught
except Exception as exc: # noqa: BLE001
failed.append(stage)
if on_error == "fail":
_raise_error(exc, stage)
+1 -1
View File
@@ -14,7 +14,7 @@ from typing import (
)
from funcy import group_by
from scmrepo.base import Base # noqa: F401, pylint: disable=unused-import
from scmrepo.base import Base # noqa: F401
from scmrepo.git import Git
from scmrepo.noscm import NoSCM
-3
View File
@@ -138,9 +138,6 @@ def restore_fields(stage: "Stage") -> None:
class Stage(params.StageParams):
# pylint:disable=no-value-for-parameter
# rwlocked() confuses pylint
def __init__( # noqa: PLR0913
self,
repo,
-2
View File
@@ -73,14 +73,12 @@ class StageLoader(Mapping):
hash_name = info.pop(Output.PARAM_HASH, None)
item.meta = Meta.from_dict(merge_file_meta_from_cloud(info))
# pylint: disable-next=protected-access
item.hash_name, item.hash_info = item._compute_hash_info_from_meta(
hash_name
)
files = get_in(checksums, [key, path, item.PARAM_FILES], None)
if files:
item.files = [merge_file_meta_from_cloud(f) for f in files]
# pylint: disable-next=protected-access
item._compute_meta_hash_info_from_files()
@classmethod
+1 -1
View File
@@ -1 +1 @@
from .fixtures import * # noqa: F403, pylint: disable=wildcard-import
from .fixtures import * # noqa: F403
-2
View File
@@ -17,7 +17,6 @@ class _BasePath:
return self.isin_or_eq(other) or other.isin(self)
def isin_or_eq(self, other):
# pylint: disable-next=no-member
return self == other or self.isin(other) # type: ignore[attr-defined]
@@ -36,7 +35,6 @@ class PathInfo(pathlib.PurePath, _BasePath):
return cls._from_parts(args) # type: ignore[attr-defined]
def as_posix(self):
# pylint: disable-next=no-member
f = self._flavour # type: ignore[attr-defined]
# Unlike original implementation [1] that uses `str()` we actually need
# to use `fspath`, because we've overridden `__str__` method to return
+2 -2
View File
@@ -1,5 +1,5 @@
from .benchmarks.fixtures import * # noqa: F403, pylint: disable=wildcard-import
from .fixtures import * # noqa: F403, pylint: disable=wildcard-import
from .benchmarks.fixtures import * # noqa: F403
from .fixtures import * # noqa: F403
def pytest_generate_tests(metafunc):
+1 -1
View File
@@ -391,7 +391,7 @@ def error_handler(func):
vals = func(*args, **kwargs)
if vals:
result["data"] = vals
except Exception as e: # noqa: BLE001, pylint: disable=broad-except
except Exception as e: # noqa: BLE001
if onerror is not None:
onerror(result, e, **kwargs)
return result
+1 -1
View File
@@ -38,7 +38,7 @@ def contains_symlink_up_to(path: "StrPath", base_path: "StrPath"):
return contains_symlink_up_to(os.path.dirname(path), base_path)
def _chmod(func, p, excinfo): # noqa: ARG001, pylint: disable=unused-argument
def _chmod(func, p, excinfo): # noqa: ARG001
perm = os.lstat(p).st_mode
perm |= stat.S_IWRITE
+5 -5
View File
@@ -1,11 +1,11 @@
from collections import defaultdict
from typing import DefaultDict
from ._common import * # noqa: F403, pylint: disable=wildcard-import
from ._json import * # noqa: F403, pylint: disable=wildcard-import
from ._py import * # noqa: F403, pylint: disable=wildcard-import
from ._toml import * # noqa: F403, pylint: disable=wildcard-import
from ._yaml import * # noqa: F403, pylint: disable=wildcard-import
from ._common import * # noqa: F403
from ._json import * # noqa: F403
from ._py import * # noqa: F403
from ._toml import * # noqa: F403
from ._yaml import * # noqa: F403
LOADERS: DefaultDict[str, LoaderFn] = defaultdict( # noqa: F405
lambda: load_yaml # noqa: F405
+1
View File
@@ -255,6 +255,7 @@ select = [
"FLY", "PERF101", "RUF",
]
show-source = true
show-fixes = true
[tool.ruff.flake8-pytest-style]
fixture-parentheses = false
+4 -4
View File
@@ -7,11 +7,11 @@ import pytest
from dvc import env
from dvc.stage import PipelineStage
from dvc.testing.fixtures import * # noqa: F403, pylint: disable=wildcard-import
from dvc.testing.fixtures import * # noqa: F403
from .dir_helpers import * # noqa: F403 # pylint: disable=wildcard-import
from .remotes import * # noqa: F403 # pylint: disable=wildcard-import
from .scripts import * # noqa: F403, pylint: disable=wildcard-import
from .dir_helpers import * # noqa: F403
from .remotes import * # noqa: F403
from .scripts import * # noqa: F403
# Prevent updater and analytics from running their processes
os.environ["DVC_TEST"] = "true"
+1 -1
View File
@@ -5,7 +5,7 @@ from funcy import first, get_in
from dvc import api
from dvc.exceptions import OutputNotFoundError, PathMissingError
from dvc.testing.api_tests import TestAPI # noqa: F401, pylint: disable=unused-import
from dvc.testing.api_tests import TestAPI # noqa: F401
from dvc.testing.tmp_dir import make_subrepo
from dvc.utils.fs import remove
-1
View File
@@ -1,6 +1,5 @@
import pytest
# pylint: disable-next=unused-argument
from tests.unit.repo.experiments.conftest import ( # noqa: F401
exp_stage,
failed_exp_stage,
+1 -1
View File
@@ -10,7 +10,7 @@ from dvc.cli import main
from dvc.exceptions import CheckoutError
from dvc.repo.open_repo import clean_repos
from dvc.stage.exceptions import StageNotFound
from dvc.testing.remote_tests import ( # noqa: F401, pylint: disable=unused-import
from dvc.testing.remote_tests import ( # noqa: F401
TestRemote,
)
from dvc.utils.fs import remove
-1
View File
@@ -1,2 +1 @@
# pylint disable=unused-argument
from tests.unit.repo.experiments.conftest import exp_stage, test_queue # noqa: F401
+1 -1
View File
@@ -1,4 +1,4 @@
from dvc_ssh.tests.fixtures import ( # noqa: F401, pylint: disable=unused-import
from dvc_ssh.tests.fixtures import ( # noqa: F401
make_ssh,
ssh,
ssh_server,