Skip to content

Commit

Permalink
pylint: enable no-else-return (#5294)
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop authored Jan 19, 2021
1 parent d038bca commit 03fc531
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 1 addition & 2 deletions dvc/cache/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
4 changes: 2 additions & 2 deletions dvc/command/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions dvc/ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
15 changes: 7 additions & 8 deletions dvc/parsing/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions dvc/parsing/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion dvc/pathspec_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
6 changes: 3 additions & 3 deletions dvc/repo/plots/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion dvc/repo/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
3 changes: 1 addition & 2 deletions dvc/scm/git/backend/gitpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"):
Expand Down
5 changes: 2 additions & 3 deletions tests/func/test_repro.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 03fc531

Please sign in to comment.