Skip to content

Commit 259af91

Browse files
authored
Fix flake8-return warnings (#4169)
2 parents 119b354 + 7ce6f39 commit 259af91

21 files changed

+45
-34
lines changed

_distutils_hack/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ def find_spec(self, fullname, path, target=None):
8383
# optimization: only consider top level modules and those
8484
# found in the CPython test suite.
8585
if path is not None and not fullname.startswith('test.'):
86-
return
86+
return None
8787

8888
method_name = 'spec_for_{fullname}'.format(**locals())
8989
method = getattr(self, method_name, lambda: None)
9090
return method()
9191

9292
def spec_for_distutils(self):
9393
if self.is_cpython():
94-
return
94+
return None
9595

9696
import importlib
9797
import importlib.abc
@@ -108,7 +108,7 @@ def spec_for_distutils(self):
108108
# setuptools from the path but only after the hook
109109
# has been loaded. Ref #2980.
110110
# In either case, fall back to stdlib behavior.
111-
return
111+
return None
112112

113113
class DistutilsLoader(importlib.abc.Loader):
114114
def create_module(self, spec):

pkg_resources/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,8 +1127,7 @@ def obtain(self, requirement, installer=None):
11271127
None is returned instead. This method is a hook that allows subclasses
11281128
to attempt other ways of obtaining a distribution before falling back
11291129
to the `installer` argument."""
1130-
if installer is not None:
1131-
return installer(requirement)
1130+
return installer(requirement) if installer else None
11321131

11331132
def __iter__(self):
11341133
"""Yield the unique project names of the available distributions"""
@@ -2833,9 +2832,7 @@ def _get_metadata(self, name):
28332832

28342833
def _get_version(self):
28352834
lines = self._get_metadata(self.PKG_INFO)
2836-
version = _version_from_file(lines)
2837-
2838-
return version
2835+
return _version_from_file(lines)
28392836

28402837
def activate(self, path=None, replace=False):
28412838
"""Ensure distribution is importable on `path` (default=sys.path)"""
@@ -3210,6 +3207,7 @@ def _find_adapter(registry, ob):
32103207
for t in types:
32113208
if t in registry:
32123209
return registry[t]
3210+
return None
32133211

32143212

32153213
def ensure_directory(path):

setuptools/command/bdist_egg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ def can_scan():
419419
"Please ask the author to include a 'zip_safe'"
420420
" setting (either True or False) in the package's setup.py"
421421
)
422+
return False
422423

423424

424425
# Attribute names of options for commands that might need to be convinced to

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/build_ext.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def get_abi3_suffix():
7676
return suffix
7777
elif suffix == '.pyd': # Windows
7878
return suffix
79+
return None
7980

8081

8182
class build_ext(_build_ext):

setuptools/command/develop.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ def install_egg_scripts(self, dist):
157157
script_text = strm.read()
158158
self.install_script(dist, script_name, script_text, script_path)
159159

160+
return None
161+
160162
def install_wrapper_scripts(self, dist):
161163
dist = VersionlessRequirement(dist)
162164
return easy_install.install_wrapper_scripts(self, dist)

setuptools/command/easy_install.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ def install_item(self, spec, download, tmpdir, deps, install_needed=False):
741741
for dist in dists:
742742
if dist in spec:
743743
return dist
744+
return None
744745

745746
def select_scheme(self, name):
746747
try:
@@ -1473,9 +1474,7 @@ def get_site_dirs():
14731474
with contextlib.suppress(AttributeError):
14741475
sitedirs.extend(site.getsitepackages())
14751476

1476-
sitedirs = list(map(normalize_path, sitedirs))
1477-
1478-
return sitedirs
1477+
return list(map(normalize_path, sitedirs))
14791478

14801479

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

setuptools/command/install.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def handle_extra_path(self):
7171
# command without --root or --single-version-externally-managed
7272
self.path_file = None
7373
self.extra_dirs = ''
74+
return None
7475

7576
def run(self):
7677
# Explicit request for old-style install? Just do it
@@ -83,6 +84,8 @@ def run(self):
8384
else:
8485
self.do_egg_install()
8586

87+
return None
88+
8689
@staticmethod
8790
def _called_from_setup(run_frame):
8891
"""
@@ -114,6 +117,8 @@ def _called_from_setup(run_frame):
114117

115118
return caller_module == 'distutils.dist' and info.function == 'run_commands'
116119

120+
return False
121+
117122
def do_egg_install(self):
118123
easy_install = self.distribution.get_command_class('easy_install')
119124

setuptools/depends.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def extract_constant(code, symbol, default=-1):
159159
else:
160160
const = default
161161

162+
return None
162163

163164
def _update_globals():
164165
"""

setuptools/discovery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def analyse_name(self):
485485
"""
486486
if self.dist.metadata.name or self.dist.name:
487487
# get_name() is not reliable (can return "UNKNOWN")
488-
return None
488+
return
489489

490490
log.debug("No `name` configuration, performing automatic discovery")
491491

0 commit comments

Comments
 (0)