diff --git a/.pylintrc b/.pylintrc index 5c74ba9eb4..6d81c3491f 100644 --- a/.pylintrc +++ b/.pylintrc @@ -184,7 +184,8 @@ disable=format, # either give multiple identifier separated by comma (,) or put this option # multiple time (only on the command line, not in the configuration file where # it should appear only once). See also the "--disable" option for examples. -enable=c-extension-no-member +enable=c-extension-no-member, + no-else-return, [REPORTS] diff --git a/dvc/cache/base.py b/dvc/cache/base.py index 759d66a48d..fd9d56d66d 100644 --- a/dvc/cache/base.py +++ b/dvc/cache/base.py @@ -355,8 +355,7 @@ def transfer(self, from_tree, from_info, jobs=None, no_progress_bar=False): jobs=jobs, no_progress_bar=no_progress_bar, ) - else: - return self._transfer_file(from_tree, from_info) + return self._transfer_file(from_tree, from_info) def _cache_is_copy(self, path_info): """Checks whether cache uses copies.""" diff --git a/dvc/command/experiments.py b/dvc/command/experiments.py index 6f2190b9c7..9bbaf2ba46 100644 --- a/dvc/command/experiments.py +++ b/dvc/command/experiments.py @@ -212,9 +212,9 @@ def _format_field(val, precision=DEFAULT_PRECISION): if isinstance(val, float): fmt = f"{{:.{precision}g}}" return fmt.format(val) - elif isinstance(val, Mapping): + if isinstance(val, Mapping): return {k: _format_field(v) for k, v in val.items()} - elif isinstance(val, list): + if isinstance(val, list): return [_format_field(x) for x in val] return str(val) diff --git a/dvc/ignore.py b/dvc/ignore.py index 05fc68f1e1..b309632ea4 100644 --- a/dvc/ignore.py +++ b/dvc/ignore.py @@ -289,8 +289,7 @@ def _is_ignored(self, path, is_dir=False): ignore_pattern = self._get_trie_pattern(dirname) if ignore_pattern: return ignore_pattern.matches(dirname, basename, is_dir) - else: - return False + return False def _is_subrepo(self, path): dirname, basename = os.path.split(os.path.normpath(path)) diff --git a/dvc/parsing/context.py b/dvc/parsing/context.py index 31d1c7f0dd..74f738af36 100644 --- a/dvc/parsing/context.py +++ b/dvc/parsing/context.py @@ -169,18 +169,17 @@ def _convert_with_meta(value, meta: Meta = None): if value is None or isinstance(value, PRIMITIVES): assert meta return Value(value, meta=meta) - elif isinstance(value, Node): + if isinstance(value, Node): return value - elif isinstance(value, (list, dict)): + if isinstance(value, (list, dict)): assert meta container = CtxDict if isinstance(value, dict) else CtxList return container(value, meta=meta) - else: - msg = ( - "Unsupported value of type " - f"'{type(value).__name__}' in '{meta}'" - ) - raise TypeError(msg) + msg = ( + "Unsupported value of type " + f"'{type(value).__name__}' in '{meta}'" + ) + raise TypeError(msg) def __repr__(self): return repr(self.data) diff --git a/dvc/parsing/interpolate.py b/dvc/parsing/interpolate.py index b01819336f..310b585d20 100644 --- a/dvc/parsing/interpolate.py +++ b/dvc/parsing/interpolate.py @@ -109,9 +109,9 @@ def wrapper(data, *args): g = rpartial(wrapper, *args) if isinstance(data, Mapping): return {g(k): g(v) for k, v in data.items()} - elif isinstance(data, Seq): + if isinstance(data, Seq): return type(data)(map(g, data)) - elif isinstance(data, str): + if isinstance(data, str): return f(data, *args) return data diff --git a/dvc/pathspec_math.py b/dvc/pathspec_math.py index 6191f7717e..3a1fcbd22f 100644 --- a/dvc/pathspec_math.py +++ b/dvc/pathspec_math.py @@ -78,7 +78,7 @@ def merge_patterns(pattern_a, prefix_a, pattern_b, prefix_b): """ if not pattern_a: return pattern_b, prefix_b - elif not pattern_b: + if not pattern_b: return pattern_a, prefix_a longest_common_dir = os.path.commonpath([prefix_a, prefix_b]) diff --git a/dvc/repo/plots/data.py b/dvc/repo/plots/data.py index afb8006dd2..7ce1e5d603 100644 --- a/dvc/repo/plots/data.py +++ b/dvc/repo/plots/data.py @@ -38,11 +38,11 @@ def plot_data(filename, revision, content): _, extension = os.path.splitext(filename.lower()) if extension == ".json": return JSONPlotData(filename, revision, content) - elif extension == ".csv": + if extension == ".csv": return CSVPlotData(filename, revision, content) - elif extension == ".tsv": + if extension == ".tsv": return CSVPlotData(filename, revision, content, delimiter="\t") - elif extension == ".yaml": + if extension == ".yaml": return YAMLPlotData(filename, revision, content) raise PlotMetricTypeError(filename) diff --git a/dvc/repo/stage.py b/dvc/repo/stage.py index 91f5217d82..0366d7da88 100644 --- a/dvc/repo/stage.py +++ b/dvc/repo/stage.py @@ -170,7 +170,7 @@ def _get_keys( if accept_group and stages.is_foreach_generated(name): return self._get_group_keys(stages, name) - elif glob: + if glob: return fnmatch.filter(stages.keys(), name) return [name] diff --git a/dvc/scm/git/backend/gitpython.py b/dvc/scm/git/backend/gitpython.py index 091749485c..aed211d6ee 100644 --- a/dvc/scm/git/backend/gitpython.py +++ b/dvc/scm/git/backend/gitpython.py @@ -377,8 +377,7 @@ def get_ref(self, name: str, follow: bool = True) -> Optional[str]: try: if follow or self.repo.head.is_detached: return self.repo.head.commit.hexsha - else: - return f"refs/heads/{self.repo.active_branch}" + return f"refs/heads/{self.repo.active_branch}" except (GitCommandError, ValueError): return None elif name.startswith("refs/heads/"): diff --git a/tests/func/test_repro.py b/tests/func/test_repro.py index ba410f5890..36c5a93a8e 100644 --- a/tests/func/test_repro.py +++ b/tests/func/test_repro.py @@ -1140,11 +1140,10 @@ def _format_dvc_line(line): if "cache:" in line or "md5:" in line: return line + " # line comment" # Format command as one word per line - elif line.startswith("cmd: "): + if line.startswith("cmd: "): pre, command = line.split(None, 1) return pre + " >\n" + "\n".join(" " + s for s in command.split()) - else: - return line + return line def test_downstream(dvc):