Skip to content

Commit 7ce6f39

Browse files
DimitriPapadopoulosabravalheri
authored andcommitted
Fix flake8-return warning
RET504 Unnecessary assignment to `...` before `return` statement
1 parent a6f6503 commit 7ce6f39

File tree

7 files changed

+8
-20
lines changed

7 files changed

+8
-20
lines changed

pkg_resources/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,9 +2832,7 @@ def _get_metadata(self, name):
28322832

28332833
def _get_version(self):
28342834
lines = self._get_metadata(self.PKG_INFO)
2835-
version = _version_from_file(lines)
2836-
2837-
return version
2835+
return _version_from_file(lines)
28382836

28392837
def activate(self, path=None, replace=False):
28402838
"""Ensure distribution is importable on `path` (default=sys.path)"""

setuptools/command/bdist_rpm.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ def run(self):
3030

3131
def _make_spec_file(self):
3232
spec = orig.bdist_rpm._make_spec_file(self)
33-
spec = [
33+
return [
3434
line.replace(
3535
"setup.py install ",
3636
"setup.py install --single-version-externally-managed ",
3737
).replace("%setup", "%setup -n %{name}-%{unmangled_version}")
3838
for line in spec
3939
]
40-
return spec

setuptools/command/easy_install.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,9 +1474,7 @@ def get_site_dirs():
14741474
with contextlib.suppress(AttributeError):
14751475
sitedirs.extend(site.getsitepackages())
14761476

1477-
sitedirs = list(map(normalize_path, sitedirs))
1478-
1479-
return sitedirs
1477+
return list(map(normalize_path, sitedirs))
14801478

14811479

14821480
def expand_paths(inputs): # noqa: C901 # is too complex (11) # FIXME

setuptools/installer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ def _fetch_build_egg_no_warn(dist, req): # noqa: C901 # is too complex (16) #
107107
dist_metadata = pkg_resources.PathMetadata(
108108
dist_location, os.path.join(dist_location, 'EGG-INFO')
109109
)
110-
dist = pkg_resources.Distribution.from_filename(
110+
return pkg_resources.Distribution.from_filename(
111111
dist_location, metadata=dist_metadata
112112
)
113-
return dist
114113

115114

116115
def strip_marker(req):

setuptools/tests/server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,4 @@ def path_to_url(path, authority=None):
8484
base = 'file:'
8585
if authority is not None:
8686
base += '//' + authority
87-
url = urllib.parse.urljoin(base, urllib.request.pathname2url(path))
88-
return url
87+
return urllib.parse.urljoin(base, urllib.request.pathname2url(path))

setuptools/tests/test_build_ext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,11 @@ def dist_with_example(self):
9898
ext3 = Extension("ext3", ["c-extension/ext3.c"])
9999

100100
path.build(files)
101-
dist = Distribution({
101+
return Distribution({
102102
"script_name": "%test%",
103103
"ext_modules": [ext1, ext2, ext3],
104104
"package_dir": {"": "src"},
105105
})
106-
return dist
107106

108107
def test_get_outputs(self, tmpdir_cwd, monkeypatch):
109108
monkeypatch.setenv('SETUPTOOLS_EXT_SUFFIX', '.mp3') # make test OS-independent

setuptools/tests/test_core_metadata.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __read_test_cases():
6464

6565
params = functools.partial(dict, base)
6666

67-
test_cases = [
67+
return [
6868
('Metadata version 1.0', params()),
6969
(
7070
'Metadata Version 1.0: Short long description',
@@ -156,8 +156,6 @@ def __read_test_cases():
156156
),
157157
]
158158

159-
return test_cases
160-
161159

162160
@pytest.mark.parametrize('name,attrs', __read_test_cases())
163161
def test_read_metadata(name, attrs):
@@ -209,7 +207,7 @@ def merge_dicts(d1, d2):
209207

210208
return d1
211209

212-
test_cases = [
210+
return [
213211
('No author, no maintainer', attrs.copy()),
214212
(
215213
'Author (no e-mail), no maintainer',
@@ -267,8 +265,6 @@ def merge_dicts(d1, d2):
267265
('Maintainer unicode', merge_dicts(attrs, {'maintainer': 'Jan Łukasiewicz'})),
268266
]
269267

270-
return test_cases
271-
272268

273269
@pytest.mark.parametrize('name,attrs', __maintainer_test_cases())
274270
def test_maintainer_author(name, attrs, tmpdir):

0 commit comments

Comments
 (0)