Skip to content

Commit

Permalink
remove pylint suppression comments (#10080)
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Nov 9, 2023
1 parent 2085bc8 commit 06565e1
Show file tree
Hide file tree
Showing 85 changed files with 106 additions and 200 deletions.
2 changes: 1 addition & 1 deletion dvc/__pyinstaller/hook-celery.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dvc/__pyinstaller/hook-dvc_task.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ruff: noqa: N999
# pylint: disable=import-error

from PyInstaller.utils.hooks import collect_submodules

hiddenimports = collect_submodules("dvc_task")
8 changes: 4 additions & 4 deletions dvc/_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions dvc/api/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dvc/api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion dvc/cachemgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
5 changes: 2 additions & 3 deletions dvc/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion dvc/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def run(self):


class CmdBaseNoRepo(CmdBase):
def __init__(self, args): # pylint: disable=super-init-not-called
def __init__(self, args):
self.args = args

os.chdir(args.cd)
Expand Down
6 changes: 3 additions & 3 deletions dvc/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@


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
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion dvc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __init__(
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
Expand Down
8 changes: 4 additions & 4 deletions dvc/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 6 additions & 9 deletions dvc/dagascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -90,7 +89,6 @@ def line(self, x0, y0, x1, y1, char): # noqa: C901, PLR0912
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
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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]
Expand Down
4 changes: 1 addition & 3 deletions dvc/dvcfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,7 @@ def _reset(self):
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

Expand Down
2 changes: 0 additions & 2 deletions dvc/fs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

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,
Expand Down
1 change: 0 additions & 1 deletion dvc/fs/callbacks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=unused-import
from contextlib import ExitStack
from typing import TYPE_CHECKING, Any, BinaryIO, Dict, Optional, Union

Expand Down
2 changes: 1 addition & 1 deletion dvc/fs/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _prepare_credentials(self, **config):
return config

@functools.cached_property
def fs( # pylint: disable=invalid-overridden-method
def fs(
self,
) -> "_DataFileSystem":
from dvc_data.fs import DataFileSystem as _DataFileSystem
Expand Down
19 changes: 6 additions & 13 deletions dvc/fs/dvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "/"

Expand All @@ -84,9 +84,7 @@ def __init__( # noqa: PLR0913
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,
Expand Down Expand Up @@ -146,7 +144,7 @@ def __init__( # noqa: PLR0913
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)

Expand Down Expand Up @@ -282,9 +280,7 @@ def _get_subrepo_info(
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))

Expand All @@ -307,9 +303,7 @@ def isdvc(self, path, **kwargs) -> bool:
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)

Expand Down Expand Up @@ -414,7 +408,7 @@ def _info( # noqa: C901, PLR0912
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:
Expand All @@ -439,7 +433,6 @@ def _prepare_credentials(self, **config) -> Dict[str, Any]:
return config

@functools.cached_property
# pylint: disable-next=invalid-overridden-method
def fs(self) -> "_DVCFileSystem":
return _DVCFileSystem(**self.fs_args)

Expand All @@ -451,7 +444,7 @@ def isdvc(self, path, **kwargs) -> bool:
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
Expand Down
4 changes: 2 additions & 2 deletions dvc/fs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ def __init__(
)

@functools.cached_property
def fs( # pylint: disable=invalid-overridden-method
def fs(
self,
) -> "FsspecGitFileSystem":
from scmrepo.fs import GitFileSystem as FsspecGitFileSystem

return FsspecGitFileSystem(**self.fs_args)

@functools.cached_property
def path(self): # pylint: disable=invalid-overridden-method
def path(self):
return self.fs.path

@property
Expand Down
8 changes: 3 additions & 5 deletions dvc/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __exit__(self, typ, value, tbck):


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):
Expand Down Expand Up @@ -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
Expand All @@ -176,7 +174,7 @@ def __init__(
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:
Expand Down
1 change: 0 additions & 1 deletion dvc/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading

0 comments on commit 06565e1

Please sign in to comment.