remove pylint suppression comments (#10080)

This commit is contained in:
skshetry
2023-11-09 20:31:50 +05:45
committed by GitHub
parent 2085bc8053
commit 06565e18b4
85 changed files with 106 additions and 200 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
# ruff: noqa: N999
# pylint: disable=import-error
from PyInstaller.utils.hooks import collect_submodules, is_module_or_submodule
# Celery dynamically imports most celery internals at runtime
+1 -1
View File
@@ -1,5 +1,5 @@
# ruff: noqa: N999
# pylint: disable=import-error
from PyInstaller.utils.hooks import collect_submodules
hiddenimports = collect_submodules("dvc_task")
+4 -4
View File
@@ -14,7 +14,7 @@ def viztracer_profile(
log_async: bool = False,
):
try:
import viztracer # pylint: disable=import-error
import viztracer
except ImportError:
print("Failed to run profiler, viztracer is not installed") # noqa: T201
yield
@@ -36,7 +36,7 @@ def yappi_profile(
separate_threads: Optional[bool] = False,
):
try:
import yappi # pylint: disable=import-error
import yappi
except ImportError:
print("Failed to run profiler, yappi is not installed") # noqa: T201
yield
@@ -76,7 +76,7 @@ def yappi_profile(
def instrument(html_output=False):
"""Run a statistical profiler"""
try:
from pyinstrument import Profiler # pylint: disable=import-error
from pyinstrument import Profiler
except ImportError:
print("Failed to run profiler, pyinstrument is not installed") # noqa: T201
yield
@@ -115,7 +115,7 @@ def profile(dump_path: Optional[str] = None):
def debug():
try:
yield
except Exception: # pylint: disable=broad-except
except Exception:
try:
import ipdb as pdb # noqa: T100, pylint: disable=import-error
except ImportError:
+1 -2
View File
@@ -1,8 +1,7 @@
from dvc.fs.dvc import _DVCFileSystem as DVCFileSystem
from .artifacts import artifacts_show
from .data import open # pylint: disable=redefined-builtin
from .data import get_url, read
from .data import get_url, open, read
from .experiments import exp_save, exp_show
from .scm import all_branches, all_commits, all_tags
from .show import metrics_show, params_show
+1 -1
View File
@@ -55,7 +55,7 @@ def get_url(path, repo=None, rev=None, remote=None):
class _OpenContextManager(GCM):
def __init__(self, func, args, kwds): # pylint: disable=super-init-not-called
def __init__(self, func, args, kwds):
self.gen = func(*args, **kwds)
self.func, self.args, self.kwds = ( # type: ignore[assignment]
func,
+1 -1
View File
@@ -137,7 +137,7 @@ def migrate_2_to_3(repo: "Repo", dry: bool = False):
src = repo.cache.legacy
dest = repo.cache.local
if dry:
oids = list(src._list_oids()) # pylint: disable=protected-access
oids = list(src._list_oids())
ui.write(
f"{len(oids)} files will be re-hashed and migrated to the DVC 3.0 cache "
"location."
+2 -3
View File
@@ -165,9 +165,9 @@ def main(argv=None): # noqa: C901, PLR0912, PLR0915
# the copied parent's standard file descriptors. If we make any logging
# calls in this state it will cause an exception due to writing to a closed
# file descriptor.
if not sys.stderr or sys.stderr.closed: # pylint: disable=using-constant-test
if not sys.stderr or sys.stderr.closed:
logging.disable()
elif not sys.stdout or sys.stdout.closed: # pylint: disable=using-constant-test
elif not sys.stdout or sys.stdout.closed:
logging.disable(logging.INFO)
args = None
@@ -231,7 +231,6 @@ def main(argv=None): # noqa: C901, PLR0912, PLR0915
except DvcParserError:
ret = 254
except Exception as exc: # noqa: BLE001, pylint: disable=broad-except
# pylint: disable=no-member
ret = _log_exceptions(exc) or 255
try:
+1 -1
View File
@@ -31,7 +31,7 @@ class CmdBase(ABC):
class CmdBaseNoRepo(CmdBase):
def __init__(self, args): # pylint: disable=super-init-not-called
def __init__(self, args):
self.args = args
os.chdir(args.cd)
+3 -3
View File
@@ -95,12 +95,12 @@ COMMANDS = [
def _find_parser(parser, cmd_cls):
defaults = parser._defaults # pylint: disable=protected-access
defaults = parser._defaults
if not cmd_cls or cmd_cls == defaults.get("func"):
parser.print_help()
raise DvcParserError
actions = parser._actions # pylint: disable=protected-access
actions = parser._actions
for action in actions:
if not isinstance(action.choices, dict):
# NOTE: we are only interested in subparsers
@@ -112,7 +112,7 @@ def _find_parser(parser, cmd_cls):
class DvcParser(argparse.ArgumentParser):
"""Custom parser class for dvc CLI."""
def error(self, message, cmd_cls=None): # pylint: disable=arguments-differ
def error(self, message, cmd_cls=None):
logger.error(message)
_find_parser(self, cmd_cls)
+1 -1
View File
@@ -96,7 +96,7 @@ class Config(dict):
config: Optional["DictStrAny"] = None,
remote: Optional[str] = None,
remote_config: Optional["DictStrAny"] = None,
): # pylint: disable=super-init-not-called
):
from dvc.fs import LocalFileSystem
dvc_dir = os.fspath(dvc_dir) if dvc_dir else None
+4 -4
View File
@@ -75,18 +75,18 @@ def _fork_process() -> int:
return pid
except OSError:
logger.exception("failed at first fork")
os._exit(1) # pylint: disable=protected-access
os._exit(1)
os.setsid() # type: ignore[attr-defined] # pylint: disable=no-member
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) # pylint: disable=protected-access
os._exit(0)
except OSError:
logger.exception("failed at second fork")
os._exit(1) # pylint: disable=protected-access
os._exit(1)
# disconnect from the terminal
fd = os.open(os.devnull, os.O_RDWR)
+6 -9
View File
@@ -22,17 +22,16 @@ class VertexViewer:
HEIGHT = 3 # top and bottom box edges + text
def __init__(self, name):
# pylint: disable=invalid-name
self._h = self.HEIGHT # top and bottom box edges + text
self._w = len(name) + 2 # right and left bottom edges + text
@property
def h(self): # pylint: disable=invalid-name
def h(self):
"""Height of the box."""
return self._h
@property
def w(self): # pylint: disable=invalid-name
def w(self):
"""Width of the box."""
return self._w
@@ -90,7 +89,6 @@ class AsciiCanvas:
y1 (int): y coordinate where the line should end.
char (str): character to draw the line with.
"""
# pylint: disable=too-many-arguments, too-many-branches
if x0 > x1:
x1, x0 = x0, x1
y1, y0 = y0, y1
@@ -234,11 +232,11 @@ def draw(vertices, edges):
| 1 |
+---+
"""
# pylint: disable=too-many-locals
# NOTE: coordinates might me negative, so we need to shift
# everything to the positive plane before we actually draw it.
Xs = [] # noqa: N806, pylint: disable=invalid-name
Ys = [] # noqa: N806, pylint: disable=invalid-name
Xs = [] # noqa: N806
Ys = [] # noqa: N806
sug = _build_sugiyama_layout(vertices, edges)
@@ -250,7 +248,7 @@ def draw(vertices, edges):
Ys.append(vertex.view.xy[1] + vertex.view.h)
for edge in sug.g.sE:
for x, y in edge.view._pts: # pylint: disable=protected-access
for x, y in edge.view._pts:
Xs.append(x)
Ys.append(y)
@@ -266,7 +264,6 @@ def draw(vertices, edges):
# NOTE: first draw edges so that node boxes could overwrite them
for edge in sug.g.sE:
# pylint: disable=protected-access
assert len(edge.view._pts) > 1
for index in range(1, len(edge.view._pts)):
start = edge.view._pts[index - 1]
+1 -3
View File
@@ -237,9 +237,7 @@ class ProjectFile(FileMixin):
self.__dict__.pop("resolver", None)
self.__dict__.pop("stages", None)
def dump(
self, stage, update_pipeline=True, update_lock=True, **kwargs
): # pylint: disable=arguments-differ
def dump(self, stage, update_pipeline=True, update_lock=True, **kwargs):
"""Dumps given stage appropriately in the dvcfile."""
from dvc.stage import PipelineStage
-2
View File
@@ -5,8 +5,6 @@ from dvc_http import HTTPFileSystem, HTTPSFileSystem # noqa: F401
from dvc.config import ConfigError as RepoConfigError
from dvc.config_schema import SCHEMA, Invalid
# pylint: disable=unused-import
from dvc_objects.fs import ( # noqa: F401
LocalFileSystem,
MemoryFileSystem,
-1
View File
@@ -1,4 +1,3 @@
# pylint: disable=unused-import
from contextlib import ExitStack
from typing import TYPE_CHECKING, Any, BinaryIO, Dict, Optional, Union
+1 -1
View File
@@ -22,7 +22,7 @@ class DataFileSystem(FileSystem):
return config
@functools.cached_property
def fs( # pylint: disable=invalid-overridden-method
def fs(
self,
) -> "_DataFileSystem":
from dvc_data.fs import DataFileSystem as _DataFileSystem
+6 -13
View File
@@ -72,7 +72,7 @@ def _get_dvc_path(dvc_fs, subkey):
return dvc_fs.path.join(*subkey) if subkey else ""
class _DVCFileSystem(AbstractFileSystem): # pylint:disable=abstract-method
class _DVCFileSystem(AbstractFileSystem):
cachable = False
root_marker = "/"
@@ -84,9 +84,7 @@ class _DVCFileSystem(AbstractFileSystem): # pylint:disable=abstract-method
subrepos: bool = False,
repo_factory: Optional[RepoFactory] = None,
fo: Optional[str] = None,
# pylint:disable-next=unused-argument
target_options: Optional[Dict[str, Any]] = None, # noqa: ARG002
# pylint:disable-next=unused-argument
target_protocol: Optional[str] = None, # noqa: ARG002
config: Optional["DictStrAny"] = None,
remote: Optional[str] = None,
@@ -146,7 +144,7 @@ class _DVCFileSystem(AbstractFileSystem): # pylint:disable=abstract-method
remote_config=remote_config,
)
assert repo is not None
# pylint: disable=protected-access
repo_factory = repo._fs_conf["repo_factory"]
self._repo_stack.enter_context(repo)
@@ -282,9 +280,7 @@ class _DVCFileSystem(AbstractFileSystem): # pylint:disable=abstract-method
dvc_fs = self._datafss.get(repo_key)
return repo, dvc_fs, subkey
def _open(
self, path, mode="rb", **kwargs
): # pylint: disable=arguments-renamed, arguments-differ
def _open(self, path, mode="rb", **kwargs):
if mode != "rb":
raise OSError(errno.EROFS, os.strerror(errno.EROFS))
@@ -307,9 +303,7 @@ class _DVCFileSystem(AbstractFileSystem): # pylint:disable=abstract-method
except FileNotFoundError:
return False
def ls( # pylint: disable=arguments-differ # noqa: C901
self, path, detail=True, dvc_only=False, **kwargs
):
def ls(self, path, detail=True, dvc_only=False, **kwargs): # noqa: C901
key = self._get_key_from_relative(path)
repo, dvc_fs, subkey = self._get_subrepo_info(key)
@@ -414,7 +408,7 @@ class _DVCFileSystem(AbstractFileSystem): # pylint:disable=abstract-method
info["name"] = path
return info
def get_file(self, rpath, lpath, **kwargs): # pylint: disable=arguments-differ
def get_file(self, rpath, lpath, **kwargs):
key = self._get_key_from_relative(rpath)
fs_path = self._from_key(key)
try:
@@ -439,7 +433,6 @@ class DVCFileSystem(FileSystem):
return config
@functools.cached_property
# pylint: disable-next=invalid-overridden-method
def fs(self) -> "_DVCFileSystem":
return _DVCFileSystem(**self.fs_args)
@@ -451,7 +444,7 @@ class DVCFileSystem(FileSystem):
return self.fs.isdvc(path, **kwargs)
@property
def path(self) -> Path: # pylint: disable=invalid-overridden-method
def path(self) -> Path:
return self.fs.path
@property
+2 -2
View File
@@ -39,7 +39,7 @@ class GitFileSystem(FileSystem): # pylint:disable=abstract-method
)
@functools.cached_property
def fs( # pylint: disable=invalid-overridden-method
def fs(
self,
) -> "FsspecGitFileSystem":
from scmrepo.fs import GitFileSystem as FsspecGitFileSystem
@@ -47,7 +47,7 @@ class GitFileSystem(FileSystem): # pylint:disable=abstract-method
return FsspecGitFileSystem(**self.fs_args)
@functools.cached_property
def path(self): # pylint: disable=invalid-overridden-method
def path(self):
return self.fs.path
@property
+3 -5
View File
@@ -59,7 +59,7 @@ class LockBase(ABC):
class LockNoop(LockBase):
def __init__(self, *args, **kwargs): # pylint: disable=super-init-not-called
def __init__(self, *args, **kwargs):
self._lock = False
def lock(self):
@@ -149,9 +149,7 @@ class HardlinkLock(flufl.lock.Lock, LockBase):
tmp_dir (str): a directory to store claim files.
"""
def __init__(
self, lockfile, tmp_dir=None, **kwargs
): # pylint: disable=super-init-not-called
def __init__(self, lockfile, tmp_dir=None, **kwargs):
import socket
self._tmp_dir = tmp_dir
@@ -176,7 +174,7 @@ class HardlinkLock(flufl.lock.Lock, LockBase):
self._owned = True
self._retry_errnos = []
def lock(self): # pylint: disable=arguments-differ
def lock(self):
try:
super().lock(timedelta(seconds=DEFAULT_TIMEOUT))
except flufl.lock.TimeOutError:
-1
View File
@@ -33,7 +33,6 @@ def add_logging_level(level_name, level_num, method_name=None):
def log_for_level(self, message, *args, **kwargs):
if self.isEnabledFor(level_num):
# pylint: disable=protected-access
self._log(level_num, message, args, **kwargs)
def log_to_root(message, *args, **kwargs):
+1 -4
View File
@@ -679,8 +679,6 @@ class Output:
return False
return self.fs.isfile(self.fs_path)
# pylint: disable=no-member
def ignore(self) -> None:
if not self.use_scm_ignore:
return
@@ -1021,7 +1019,6 @@ class Output:
self.ignore_remove()
def move(self, out):
# pylint: disable=no-member
if self.protocol == "local" and self.use_scm_ignore:
self.repo.scm_context.ignore_remove(self.fspath)
@@ -1132,7 +1129,7 @@ class Output:
try:
self.get_dir_cache(jobs=jobs, remote=remote)
except RemoteMissingDepsError: # pylint: disable=try-except-raise
except RemoteMissingDepsError:
raise
except DvcException:
logger.debug("failed to pull cache for '%s'", self)
+1 -3
View File
@@ -324,9 +324,7 @@ class Context(CtxDict):
keys = [keys] if isinstance(keys, str) else keys
params_file.update({key: node.value for key in keys})
def select(
self, key: str, unwrap: bool = False
): # pylint: disable=arguments-differ
def select(self, key: str, unwrap: bool = False):
"""Select the item using key, similar to `__getitem__`
but can track the usage of the data on interpolation
as well and can get from nested data structure by using
+2 -3
View File
@@ -37,7 +37,6 @@ logger = logging.getLogger(__name__)
@contextmanager
def lock_repo(repo: "Repo"):
# pylint: disable=protected-access
depth: int = repo._lock_depth
repo._lock_depth += 1
@@ -588,7 +587,7 @@ class Repo:
path = os.path.join(self.tmp_dir, "btime")
try:
with open(path, "x"): # pylint: disable=unspecified-encoding
with open(path, "x"):
pass
except FileNotFoundError:
return None
@@ -658,7 +657,7 @@ class Repo:
self._data_index.close()
def _reset(self):
self.scm._reset() # pylint: disable=protected-access
self.scm._reset()
self.state.close()
if "dvcfs" in self.__dict__:
self.dvcfs.close()
-1
View File
@@ -140,7 +140,6 @@ def progress_iter(stages: Dict[str, StageInfo]) -> Iterator[Tuple[str, StageInfo
pbar.refresh()
yield item, stage_info
if total == 1: # restore bar format for stats
# pylint: disable=no-member
pbar.bar_format = pbar.BAR_FMT_DEFAULT
+1 -1
View File
@@ -101,7 +101,7 @@ class Artifacts:
for (
dvcfile,
dvcfile_artifacts,
) in self.repo.index._artifacts.items(): # pylint: disable=protected-access
) in self.repo.index._artifacts.items():
dvcyaml = relpath(dvcfile, self.repo.root_dir)
artifacts[dvcyaml] = {}
for name, value in dvcfile_artifacts.items():
+3 -3
View File
@@ -103,7 +103,7 @@ def brancher( # noqa: E302
self.fs = saved_fs
self.root_dir = saved_root
self.dvc_dir = saved_dvc_dir
self._reset() # pylint: disable=protected-access
self._reset()
def _switch_fs(
@@ -129,7 +129,7 @@ def _switch_fs(
repo.fs = fs
repo.root_dir = root_dir
repo.dvc_dir = fs.path.join(root_dir, repo.DVC_DIR)
repo._reset() # pylint: disable=protected-access
repo._reset()
if cwd_parts:
cwd = repo.fs.path.join("/", *cwd_parts)
@@ -162,4 +162,4 @@ def switch(repo: "Repo", rev: str) -> Iterator[str]:
repo.fs = saved_fs
repo.root_dir = saved_root
repo.dvc_dir = saved_dvc_dir
repo._reset() # pylint: disable=protected-access
repo._reset()
+1 -1
View File
@@ -129,7 +129,7 @@ def checkout( # noqa: C901
),
):
raise CheckoutErrorSuggestGit(target) from exc
raise # pylint: disable=misplaced-bare-raise
raise
view = self.index.targets_view(
targets,
+2 -2
View File
@@ -104,8 +104,8 @@ def commit_2_to_3(repo: "Repo", dry: bool = False):
ui.write("Entries in following DVC files will be migrated to the 3.0 format:")
ui.write("\n".join(sorted(f"\t{file}" for file in migrated)))
return
for stage, filter_info in view._stage_infos: # pylint: disable=protected-access
outs_filter = view._outs_filter # pylint: disable=protected-access
for stage, filter_info in view._stage_infos:
outs_filter = view._outs_filter
outs = {
out
for out in stage.filter_outs(filter_info)
+1 -1
View File
@@ -259,7 +259,7 @@ class BaseExecutor(ABC):
chain(
_collect_top_level_metrics(repo),
_collect_top_level_params(repo),
repo.index._plot_sources, # pylint: disable=protected-access
repo.index._plot_sources,
)
)
+2 -2
View File
@@ -39,7 +39,7 @@ def remove_tasks( # noqa: C901, PLR0912
for (
msg,
queue_entry,
) in celery_queue._iter_queued(): # pylint: disable=protected-access
) in celery_queue._iter_queued():
if queue_entry.stash_rev in stash_revs and msg.delivery_tag:
celery_queue.celery.reject(msg.delivery_tag)
finally:
@@ -49,7 +49,7 @@ def remove_tasks( # noqa: C901, PLR0912
for (
msg,
queue_entry,
) in celery_queue._iter_processed(): # pylint: disable=protected-access
) in celery_queue._iter_processed():
if queue_entry not in done_entry_set:
continue
task_id = msg.headers["id"]
+1 -1
View File
@@ -72,7 +72,7 @@ def collect_exp(
else:
logger.debug("Experiment failed (Exec result was None)")
celery_queue.stash_failed(entry)
except Exception: # pylint: disable=broad-except
except Exception:
# Log exceptions but do not re-raise so that task chain execution
# continues
logger.exception("Failed to collect experiment")
+1 -1
View File
@@ -158,7 +158,7 @@ class WorkspaceQueue(BaseStashQueue):
return None
@staticmethod
def collect_executor( # pylint: disable=unused-argument
def collect_executor(
exp: "Experiments",
executor: "BaseExecutor", # noqa: ARG004
exec_result: "ExecutorResult",
+2 -10
View File
@@ -144,11 +144,7 @@ def _build_rows(
row["Created"] = format_time(
baseline.data.timestamp, fill_value=fill_value, **kwargs
)
row.update(
_data_cells( # pylint: disable=missing-kwoa
baseline, fill_value=fill_value, **kwargs
)
)
row.update(_data_cells(baseline, fill_value=fill_value, **kwargs))
yield tuple(row.values())
if baseline.experiments:
if sort_by:
@@ -262,11 +258,7 @@ def _exp_range_rows(
row["Created"] = format_time(
exp.data.timestamp, fill_value=fill_value, **kwargs
)
row.update(
_data_cells( # pylint: disable=missing-kwoa
exp, fill_value=fill_value, **kwargs
)
)
row.update(_data_cells(exp, fill_value=fill_value, **kwargs))
yield tuple(row.values())
+1 -1
View File
@@ -150,7 +150,7 @@ class ApplyStash(Stash):
yield stash_rev
if stash_rev:
self._apply_difference(stash_rev, rev)
except Exception: # pylint: disable=broad-except
except Exception:
self.revert_workspace()
raise
+1 -1
View File
@@ -68,7 +68,7 @@ def unlocked_repo(f):
@wraps(f)
def wrapper(exp, *args, **kwargs):
exp.repo.lock.unlock()
exp.repo._reset() # pylint: disable=protected-access
exp.repo._reset()
try:
ret = f(exp, *args, **kwargs)
finally:
+2 -2
View File
@@ -62,7 +62,7 @@ def _collect_indexes( # noqa: PLR0913
idx.data["repo"].onerror = _make_index_onerror(onerror, rev)
indexes[rev or "workspace"] = idx
except Exception as exc: # pylint: disable=broad-except
except Exception as exc:
if onerror:
onerror(rev, None, exc)
collection_exc = exc
@@ -167,7 +167,7 @@ def fetch( # noqa: C901, PLR0913
data,
jobs=jobs,
callback=pb.as_callback(),
) # pylint: disable=assignment-from-no-return
)
finally:
for fs_index in data:
fs_index.close()
+2 -3
View File
@@ -243,7 +243,6 @@ class Index:
onerror = onerror or repo.stage_collection_error_handler
for _, idx in collect_files(repo, onerror=onerror):
# pylint: disable=protected-access
stages.extend(idx.stages)
metrics.update(idx._metrics)
plots.update(idx._plots)
@@ -505,7 +504,7 @@ class Index:
if not onerror:
def onerror(_target, _exc):
raise # pylint: disable=misplaced-bare-raise
raise
targets = ensure_list(targets)
if not targets:
@@ -616,7 +615,7 @@ class _DataPrefixes(NamedTuple):
class IndexView:
"""Read-only view of Index.data using filtered stages."""
def __init__( # pylint: disable=redefined-outer-name
def __init__(
self,
index: Index,
stage_infos: Iterable["StageInfo"],
+1 -1
View File
@@ -51,7 +51,7 @@ def diff(
repo: "Repo",
a_rev: str = "HEAD",
b_rev: str = "workspace",
all: bool = False, # noqa: A002 # pylint: disable=redefined-builtin
all: bool = False, # noqa: A002
**kwargs,
) -> DiffResult:
if repo.scm.no_commits:
+1 -1
View File
@@ -33,7 +33,7 @@ logger = logging.getLogger(__name__)
def _collect_top_level_metrics(repo: "Repo") -> Iterator[str]:
top_metrics = repo.index._metrics # pylint: disable=protected-access
top_metrics = repo.index._metrics
for dvcfile, metrics in top_metrics.items():
wdir = repo.fs.path.relpath(repo.fs.path.parent(dvcfile), repo.root_dir)
for file in metrics:
+1 -1
View File
@@ -9,7 +9,7 @@ def diff(
repo: "Repo",
a_rev: str = "HEAD",
b_rev: str = "workspace",
all: bool = False, # noqa: A002 # pylint: disable=redefined-builtin
all: bool = False, # noqa: A002
**kwargs,
) -> "DiffResult":
if repo.scm.no_commits:
+1 -1
View File
@@ -19,7 +19,7 @@ logger = logging.getLogger(__name__)
def _collect_top_level_params(repo: "Repo") -> Iterator[str]:
top_params = repo.index._params # pylint: disable=protected-access
top_params = repo.index._params
for dvcfile, params in top_params.items():
wdir = repo.fs.path.relpath(repo.fs.path.parent(dvcfile), repo.root_dir)
for file in params:
+1 -1
View File
@@ -474,7 +474,7 @@ def _resolve_definitions(
def _collect_pipeline_files(repo, targets: List[str], props, onerror=None):
result: Dict[str, Dict] = {}
top_plots = repo.index._plots # pylint: disable=protected-access
top_plots = repo.index._plots
for dvcfile, plots_def in top_plots.items():
dvcfile_path = _relpath(repo.dvcfs, dvcfile)
dvcfile_defs_dict: Dict[str, Union[Dict, None]] = {}
+1 -1
View File
@@ -116,7 +116,7 @@ def push( # noqa: C901, PLR0913
data,
jobs=jobs,
callback=pb.as_callback(),
) # pylint: disable=assignment-from-no-return
)
finally:
ws_idx = indexes.get("workspace")
if ws_idx is not None:
+3 -3
View File
@@ -136,12 +136,12 @@ class SCMContext:
self.files_to_track = set()
def __enter__(self) -> "SCMContext":
self._cm = self() # pylint: disable=attribute-defined-outside-init
return self._cm.__enter__() # pylint: disable=no-member
self._cm = self()
return self._cm.__enter__()
def __exit__(self, *exc_args) -> None:
assert self._cm
self._cm.__exit__(*exc_args) # pylint: disable=no-member
self._cm.__exit__(*exc_args)
def scm_context(method, autostage: Optional[bool] = None, quiet: Optional[bool] = None):
-2
View File
@@ -37,8 +37,6 @@ def worktree_view_by_remotes(
push: bool = False,
**kwargs: Any,
) -> Iterable[Tuple[Optional[str], "IndexView"]]:
# pylint: disable=protected-access
from dvc.repo.index import IndexView
def outs_filter(view: "IndexView", remote: Optional[str]):
+1 -3
View File
@@ -100,9 +100,7 @@ def SCM(
...
def SCM(
root_dir, *, search_parent_directories=True, no_scm=False
): # pylint: disable=invalid-name
def SCM(root_dir, *, search_parent_directories=True, no_scm=False):
"""Returns SCM instance that corresponds to a repo at the specified
path.
+2 -2
View File
@@ -125,7 +125,7 @@ def restore_fields(stage: "Stage") -> None:
return
# will be used to restore comments later
# pylint: disable=protected-access
stage._stage_text = old._stage_text
stage.meta = old.meta
stage.desc = old.desc
@@ -809,7 +809,7 @@ class PipelineStage(Stage):
assert isinstance(self.dvcfile, ProjectFile)
self.dvcfile._reset() # pylint: disable=protected-access
self.dvcfile._reset()
return self.dvcfile.stages[self.name]
def _status_stage(self, ret) -> None:
+3 -3
View File
@@ -16,7 +16,7 @@ def rwlocked(call, read=None, write=None):
if write is None:
write = []
stage = call._args[0] # pylint: disable=protected-access
stage = call._args[0]
assert stage.repo.lock.is_locked
@@ -47,7 +47,7 @@ def unlocked_repo(f):
@wraps(f)
def wrapper(stage, *args, **kwargs):
stage.repo.lock.unlock()
stage.repo._reset() # pylint: disable=protected-access
stage.repo._reset()
try:
ret = f(stage, *args, **kwargs)
finally:
@@ -65,7 +65,7 @@ def relock_repo(f):
ret = f(stage, *args, **kwargs)
finally:
stage.repo.lock.unlock()
stage.repo._reset() # pylint: disable=protected-access
stage.repo._reset()
return ret
return wrapper
+2 -2
View File
@@ -123,7 +123,7 @@ class StageLoader(Mapping):
def lockfile_needs_update(self):
# if lockfile does not have all of the entries that dvc.yaml says it
# should have, provide a debug message once
# pylint: disable=protected-access
lockfile = self.dvcfile._lockfile.relpath
logger.debug("Lockfile '%s' needs to be updated.", lockfile)
@@ -207,7 +207,7 @@ class SingleStageLoader(Mapping):
dvcfile.repo.fs, dvcfile.path, d.get(Stage.PARAM_WDIR)
)
stage = loads_from(Stage, dvcfile.repo, path, wdir, d)
stage._stage_text = stage_text # pylint: disable=protected-access
stage._stage_text = stage_text
stage.deps = dependency.loadd_from(stage, d.get(Stage.PARAM_DEPS) or [])
stage.outs = output.loadd_from(stage, d.get(Stage.PARAM_OUTS) or [])
return stage
-1
View File
@@ -74,7 +74,6 @@ def get_executable():
def _run(executable, cmd, **kwargs):
# pylint: disable=protected-access
main_thread = isinstance(
threading.current_thread(),
threading._MainThread, # type: ignore[attr-defined]
+1 -1
View File
@@ -209,7 +209,7 @@ def to_single_stage_file(stage: "Stage", **kwargs):
# - reparse the same yaml text with a slow but smart ruamel yaml parser
# - apply changes to a returned structure
# - serialize it
text = stage._stage_text # pylint: disable=protected-access
text = stage._stage_text
if text is None:
return state
+1 -1
View File
@@ -294,7 +294,7 @@ def _get_stage_files(stage: "Stage") -> List[str]:
file = stage.dvcfile
ret.append(file.relpath)
if isinstance(file, ProjectFile):
ret.append(file._lockfile.relpath) # pylint: disable=protected-access
ret.append(file._lockfile.relpath)
for dep in stage.deps:
if (
-2
View File
@@ -4,8 +4,6 @@ from dvc import api
from dvc.api import DVCFileSystem
from dvc.utils.fs import remove
# pylint: disable=unused-argument
class TestAPI:
def test_get_url(self, tmp_dir, dvc, remote):
@@ -1,3 +1,2 @@
# pylint: disable=unused-argument
def test_add(bench_dvc, tmp_dir, dvc, dataset):
bench_dvc("add", dataset)
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
import os
import pytest
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
from shutil import rmtree
import pytest
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
def test_diff(bench_dvc, tmp_dir, scm, dvc, make_dataset):
dataset = make_dataset(cache=True, files=True, dvcfile=True, commit=True)
bench_dvc("diff")
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
import pytest
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
def test_gc(bench_dvc, tmp_dir, dvc, make_dataset):
make_dataset(files=False, cache=True, dvcfile=False)
bench_dvc("gc", "-f", "-w")
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
def test_get(bench_dvc, tmp_dir, scm, dvc, make_dataset, remote):
dataset = make_dataset(
cache=False, files=False, dvcfile=True, commit=True, remote=True
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
def test_get_url(bench_dvc, tmp_dir, scm, dvc, make_dataset):
dataset = make_dataset(
cache=False, files=True, dvcfile=False, commit=False, remote=False
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
def test_import(bench_dvc, tmp_dir, scm, dvc, make_dataset, remote):
dataset = make_dataset(
cache=False, files=False, dvcfile=True, commit=True, remote=True
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
def test_import_url(bench_dvc, tmp_dir, scm, dvc, make_dataset):
dataset = make_dataset(
cache=False, files=True, dvcfile=False, commit=False, remote=False
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
import shutil
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
def test_list(bench_dvc, tmp_dir, scm, dvc, make_dataset, remote):
make_dataset(cache=False, files=False, dvcfile=True, commit=True, remote=True)
bench_dvc("list", tmp_dir)
@@ -3,10 +3,6 @@ import pytest
from dvc.repo import Repo
from dvc.testing.benchmarks.fixtures import _pull
# pylint: disable=redefined-outer-name,unused-argument
# pylint: disable=unused-argument
@pytest.mark.requires(minversion=(2, 34, 0), reason="top-level plots not supported")
def test_plots(project, bench_dvc):
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
def test_pull(bench_dvc, tmp_dir, dvc, make_dataset, remote):
make_dataset(cache=False, dvcfile=True, files=False, remote=True)
bench_dvc("pull")
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
def test_push(bench_dvc, tmp_dir, dvc, make_dataset, remote):
make_dataset(cache=True, dvcfile=True, files=False)
bench_dvc("push")
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
def test_status(bench_dvc, tmp_dir, dvc, make_dataset):
dataset = make_dataset(files=True, dvcfile=True, cache=True)
bench_dvc("status")
@@ -1,4 +1,3 @@
# pylint: disable=unused-argument
def test_update(bench_dvc, tmp_dir, dvc, make_dataset):
dataset = make_dataset(
cache=False, files=True, dvcfile=False, commit=False, remote=False
@@ -9,8 +9,6 @@ import sys
import pytest
# pylint: disable=unused-argument,unexpected-keyword-arg
@pytest.mark.skipif(sys.version_info < (3, 10), reason="requires 3.10 glob.glob")
def test_partial_add(bench_dvc, tmp_dir, dvc, dataset, remote):
@@ -1,7 +1,5 @@
import shutil
# pylint: disable=unused-argument
def test_sharing(bench_dvc, tmp_dir, dvc, dataset, remote):
bench_dvc("add", dataset)
+1 -1
View File
@@ -1 +1 @@
from .fixtures import * # noqa: F403 # pylint: disable=wildcard-import
from .fixtures import * # noqa: F403
-2
View File
@@ -8,8 +8,6 @@ from dulwich.porcelain import clone
from funcy import first
from packaging import version
# pylint: disable=redefined-outer-name,unused-argument
@pytest.fixture(scope="session")
def bench_config(request):
+5 -7
View File
@@ -7,8 +7,6 @@ import pytest
from .scripts import copy_script
# pylint: disable=redefined-outer-name,unused-argument
__all__ = [
"make_tmp_dir",
"tmp_dir",
@@ -40,7 +38,7 @@ CACHE: Dict[Tuple[bool, bool, bool], str] = {}
@pytest.fixture(scope="session")
def make_tmp_dir(tmp_path_factory, request, worker_id):
def make(name, *, scm=False, dvc=False, subdir=False): # pylint: disable=W0621
def make(name, *, scm=False, dvc=False, subdir=False):
from shutil import copytree, ignore_patterns
from dvc.repo import Repo
@@ -129,7 +127,7 @@ def local_cloud(make_cloud):
@pytest.fixture
def make_remote(tmp_dir, dvc, make_cloud): # noqa: ARG001
def _make_remote(name, typ="local", **kwargs):
cloud = make_cloud(typ) # pylint: disable=W0621
cloud = make_cloud(typ)
tmp_dir.add_remote(name=name, config=cloud.config, **kwargs)
return cloud
@@ -139,7 +137,7 @@ def make_remote(tmp_dir, dvc, make_cloud): # noqa: ARG001
@pytest.fixture
def make_remote_version_aware(tmp_dir, dvc, make_cloud_version_aware): # noqa: ARG001
def _make_remote(name, typ="local", **kwargs):
cloud = make_cloud_version_aware(typ) # pylint: disable=W0621
cloud = make_cloud_version_aware(typ)
config = dict(cloud.config)
config["version_aware"] = True
tmp_dir.add_remote(name=name, config=config, **kwargs)
@@ -151,7 +149,7 @@ def make_remote_version_aware(tmp_dir, dvc, make_cloud_version_aware): # noqa:
@pytest.fixture
def make_remote_worktree(tmp_dir, dvc, make_cloud_version_aware): # noqa: ARG001
def _make_remote(name, typ="local", **kwargs):
cloud = make_cloud_version_aware(typ) # pylint: disable=W0621
cloud = make_cloud_version_aware(typ)
config = dict(cloud.config)
config["worktree"] = True
tmp_dir.add_remote(name=name, config=config, **kwargs)
@@ -188,7 +186,7 @@ def make_workspace(tmp_dir, dvc, make_cloud):
def _make_workspace(name, typ="local"):
from dvc.cachemgr import CacheManager
cloud = make_cloud(typ) # pylint: disable=W0621
cloud = make_cloud(typ)
tmp_dir.add_remote(name=name, config=cloud.config, default=False)
tmp_dir.add_remote(
+4 -7
View File
@@ -1,4 +1,3 @@
# pylint: disable=protected-access
import os
import pathlib
import posixpath
@@ -32,9 +31,7 @@ class PathInfo(pathlib.PurePath, _BasePath):
def __new__(cls, *args):
# Construct a proper subclass depending on current os
if cls is PathInfo:
cls = ( # pylint: disable=self-cls-assignment
WindowsPathInfo if os.name == "nt" else PosixPathInfo
)
cls = WindowsPathInfo if os.name == "nt" else PosixPathInfo
return cls._from_parts(args) # type: ignore[attr-defined]
@@ -82,7 +79,7 @@ class PathInfo(pathlib.PurePath, _BasePath):
and self._cparts[:n] == other._cparts # type: ignore[attr-defined]
)
def relative_to(self, other): # pylint: disable=arguments-differ
def relative_to(self, other):
# pathlib relative_to raises exception when one path is not a direct
# descendant of the other when os.path.relpath would return abspath.
# For DVC PathInfo we only need the relpath behavior.
@@ -209,7 +206,7 @@ class URLInfo(_BasePath):
return self._spath
@cached_property
def _path( # pylint: disable=method-hidden
def _path(
self,
) -> "_URLPathInfo":
return _URLPathInfo(self._spath)
@@ -296,7 +293,7 @@ class HTTPURLInfo(URLInfo):
params=None,
query=None,
fragment=None,
): # pylint: disable=arguments-differ
):
assert bool(host) ^ bool(netloc)
if netloc is not None:
+7 -15
View File
@@ -7,8 +7,6 @@ from dvc.stage.cache import RunCacheNotSupported
from dvc.utils.fs import remove
from dvc_data.hashfile.tree import Tree
# pylint: disable=unused-argument
def _check_status(status, **kwargs):
for key in ("ok", "missing", "new", "deleted"):
@@ -17,7 +15,7 @@ def _check_status(status, **kwargs):
class TestRemote:
def test(self, tmp_dir, dvc, remote): # pylint: disable=W0613
def test(self, tmp_dir, dvc, remote):
(stage,) = tmp_dir.dvc_gen("foo", "foo")
out = stage.outs[0]
cache = out.cache_path
@@ -169,9 +167,7 @@ class TestRemote:
class TestRemoteVersionAware:
def test_file(
self, tmp_dir, dvc, run_copy, remote_version_aware
): # pylint: disable=W0613
def test_file(self, tmp_dir, dvc, run_copy, remote_version_aware):
(stage,) = tmp_dir.dvc_gen("foo", "foo")
run_copy("foo", "foo_copy", name="copy")
@@ -200,9 +196,7 @@ class TestRemoteVersionAware:
assert (tmp_dir / "foo.dvc").read_text() == foo_dvc
assert (tmp_dir / "dvc.lock").read_text() == dvc_lock
def test_dir(
self, tmp_dir, dvc, run_copy, remote_version_aware
): # pylint: disable=W0613
def test_dir(self, tmp_dir, dvc, run_copy, remote_version_aware):
(stage,) = tmp_dir.dvc_gen(
{
"data_dir": {
@@ -249,7 +243,7 @@ class TestRemoteVersionAware:
class TestRemoteWorktree:
def test_file(self, tmp_dir, dvc, remote_worktree): # pylint: disable=W0613
def test_file(self, tmp_dir, dvc, remote_worktree):
(stage,) = tmp_dir.dvc_gen("foo", "foo")
dvc.push()
@@ -264,7 +258,7 @@ class TestRemoteWorktree:
dvc.pull()
assert (tmp_dir / "foo").read_text() == "foo"
def test_dir(self, tmp_dir, dvc, remote_worktree): # pylint: disable=W0613
def test_dir(self, tmp_dir, dvc, remote_worktree):
(stage,) = tmp_dir.dvc_gen(
{
"data_dir": {
@@ -294,9 +288,7 @@ class TestRemoteWorktree:
tmp_dir / "data_dir" / "data_sub_dir" / "data_sub"
).read_text() == "data_sub"
def test_deletion(
self, tmp_dir, dvc, scm, remote_worktree # pylint: disable=W0613
):
def test_deletion(self, tmp_dir, dvc, scm, remote_worktree):
tmp_dir.dvc_gen(
{
"data_dir": {
@@ -325,7 +317,7 @@ class TestRemoteWorktree:
dvc.pull()
assert (tmp_dir / "data_dir" / "data").read_text() == "data"
def test_update(self, tmp_dir, dvc, remote_worktree): # pylint: disable=W0613
def test_update(self, tmp_dir, dvc, remote_worktree):
(foo_stage,) = tmp_dir.dvc_gen("foo", "foo")
(data_dir_stage,) = tmp_dir.dvc_gen(
{
+3 -8
View File
@@ -43,8 +43,6 @@ from global repo template to creating everything inplace, which:
- does not create unnecessary files
"""
# pylint: disable=redefined-outer-name, attribute-defined-outside-init
import os
import pathlib
import sys
@@ -71,19 +69,16 @@ class TmpDir(pathlib.Path):
def __new__(cls, *args, **kwargs):
if cls is TmpDir:
cls = ( # pylint: disable=self-cls-assignment
WindowsTmpDir if os.name == "nt" else PosixTmpDir
)
cls = WindowsTmpDir if os.name == "nt" else PosixTmpDir
# init parameter and `_init` method has been removed in Python 3.10.
kw = {"init": False} if sys.version_info < (3, 10) else {}
# pylint: disable-next=unexpected-keyword-arg
self = cls._from_parts(args, **kw) # type: ignore[attr-defined]
if not self._flavour.is_supported:
raise NotImplementedError(
f"cannot instantiate {cls.__name__!r} on your system"
)
if sys.version_info < (3, 10):
self._init() # pylint: disable=no-member
self._init()
return self
def init(self, *, scm=False, dvc=False, subdir=False):
@@ -222,7 +217,7 @@ class TmpDir(pathlib.Path):
finally:
self.scm.checkout(old)
def read_text(self, *args, **kwargs): # pylint: disable=signature-differs
def read_text(self, *args, **kwargs):
# NOTE: on windows we'll get PermissionError instead of
# IsADirectoryError when we try to `open` a directory, so we can't
# rely on exception flow control
-1
View File
@@ -55,7 +55,6 @@ def find_pager():
if not Console.isatty():
return None
# pylint: disable=redefined-outer-name
pager = os.getenv(DVC_PAGER)
if not pager:
pager = os.getenv(PAGER_ENV)
-1
View File
@@ -54,7 +54,6 @@ def console_width(table: "Table", console: "RichConsole", val: int) -> Iterator[
# NOTE: rich does not have native support for unlimited width
# via pager. we override rich table compression by setting
# console width to the full width of the table
# pylint: disable=protected-access
console_options = console.options
original = console_options.max_width
+1 -1
View File
@@ -77,7 +77,7 @@ class Updater:
try:
info = json.load(fobj)
latest = info["version"]
except Exception as e: # noqa: BLE001 # pylint: disable=W0703
except Exception as e: # noqa: BLE001
logger.trace("", exc_info=True) # type: ignore[attr-defined]
logger.debug("'%s' is not a valid json: %s", self.updater_file, e)
self.fetch()
+1 -1
View File
@@ -94,7 +94,7 @@ def apply_overrides(path: "StrPath", overrides: List[str]) -> None:
flags={"allow_objects": True},
)
OmegaConf.set_struct(new_data, True)
# pylint: disable=protected-access
ConfigLoaderImpl._apply_overrides_to_config(parsed, new_data)
new_data = OmegaConf.to_object(new_data)
except hydra_errors as e:
+1 -4
View File
@@ -7,9 +7,7 @@ if TYPE_CHECKING:
class Table(RichTable):
def add_column( # pylint: disable=arguments-differ
self, *args: Any, collapse: bool = False, **kwargs: Any
) -> None:
def add_column(self, *args: Any, collapse: bool = False, **kwargs: Any) -> None:
super().add_column(*args, **kwargs)
self.columns[-1].collapse = collapse # type: ignore[attr-defined]
@@ -48,7 +46,6 @@ class Table(RichTable):
return widths
def _collapse_widths( # type: ignore[override]
# pylint: disable=arguments-differ
self,
widths: List[int],
wrapable: List[bool],
+1 -2
View File
@@ -43,8 +43,7 @@ class ThreadPoolExecutor(futures.ThreadPoolExecutor):
tasks.update(create_taskset(len(done)))
def shutdown(self, wait=True, *, cancel_futures=False):
if sys.version_info > (3, 9): # pylint: disable=no-else-return
# pylint: disable=unexpected-keyword-arg
if sys.version_info > (3, 9):
return super().shutdown(wait=wait, cancel_futures=cancel_futures)
else: # noqa: RET505
with self._shutdown_lock:
-1
View File
@@ -1,4 +1,3 @@
# pylint: disable=unused-import
try:
from ._dvc_version import version as __version__ # type: ignore[import]
from ._dvc_version import version_tuple # type: ignore[import]