Skip to content

Commit b83ce0c

Browse files
authored
Merge pull request #3963 from pypa/debt/formatting
Apply black styling to all but vendored modules.
2 parents e3c8984 + 54795ce commit b83ce0c

File tree

94 files changed

+2838
-2164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2838
-2164
lines changed

pkg_resources/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
"pkg_resources is deprecated as an API. "
120120
"See https://setuptools.pypa.io/en/latest/pkg_resources.html",
121121
DeprecationWarning,
122-
stacklevel=2
122+
stacklevel=2,
123123
)
124124

125125

@@ -1418,7 +1418,7 @@ def _forgiving_version(version):
14181418
match = _PEP440_FALLBACK.search(version)
14191419
if match:
14201420
safe = match["safe"]
1421-
rest = version[len(safe):]
1421+
rest = version[len(safe) :]
14221422
else:
14231423
safe = "0"
14241424
rest = version

pkg_resources/tests/data/my-test-package-source/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import setuptools
2+
23
setuptools.setup(
34
name="my-test-package",
45
version="1.0",

pkg_resources/tests/test_find_distributions.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
class TestFindDistributions:
10-
1110
@pytest.fixture
1211
def target_dir(self, tmpdir):
1312
target_dir = tmpdir.mkdir('target')
@@ -36,8 +35,10 @@ def test_zipped_egg(self, target_dir):
3635
def test_zipped_sdist_one_level_removed(self, target_dir):
3736
(TESTS_DATA_DIR / 'my-test-package-zip').copy(target_dir)
3837
dists = pkg_resources.find_distributions(
39-
str(target_dir / "my-test-package.zip"))
38+
str(target_dir / "my-test-package.zip")
39+
)
4040
assert [dist.project_name for dist in dists] == ['my-test-package']
4141
dists = pkg_resources.find_distributions(
42-
str(target_dir / "my-test-package.zip"), only=True)
42+
str(target_dir / "my-test-package.zip"), only=True
43+
)
4344
assert not list(dists)

pkg_resources/tests/test_pkg_resources.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
from unittest import mock
1313

1414
from pkg_resources import (
15-
DistInfoDistribution, Distribution, EggInfoDistribution,
15+
DistInfoDistribution,
16+
Distribution,
17+
EggInfoDistribution,
1618
)
1719

1820
import pytest
@@ -82,6 +84,7 @@ def teardown_class(cls):
8284

8385
def test_resource_listdir(self):
8486
import mod
87+
8588
zp = pkg_resources.ZipProvider(mod)
8689

8790
expected_root = ['data.dat', 'mod.py', 'subdir']
@@ -95,6 +98,7 @@ def test_resource_listdir(self):
9598
assert zp.resource_listdir('nonexistent/') == []
9699

97100
import mod2
101+
98102
zp2 = pkg_resources.ZipProvider(mod2)
99103

100104
assert sorted(zp2.resource_listdir('')) == expected_subdir
@@ -110,6 +114,7 @@ def test_resource_filename_rewrites_on_change(self):
110114
subsequent call to get_resource_filename.
111115
"""
112116
import mod
117+
113118
manager = pkg_resources.ResourceManager()
114119
zp = pkg_resources.ZipProvider(mod)
115120
filename = zp.get_resource_filename(manager, 'data.dat')
@@ -174,10 +179,7 @@ def test_setuptools_not_imported(self):
174179
lines = (
175180
'import pkg_resources',
176181
'import sys',
177-
(
178-
'assert "setuptools" not in sys.modules, '
179-
'"setuptools was imported"'
180-
),
182+
('assert "setuptools" not in sys.modules, ' '"setuptools was imported"'),
181183
)
182184
cmd = [sys.executable, '-c', '; '.join(lines)]
183185
subprocess.check_call(cmd)
@@ -198,7 +200,7 @@ def make_test_distribution(metadata_path, metadata):
198200
with open(metadata_path, 'wb') as f:
199201
f.write(metadata)
200202
dists = list(pkg_resources.distributions_from_metadata(dist_dir))
201-
dist, = dists
203+
(dist,) = dists
202204

203205
return dist
204206

@@ -244,7 +246,7 @@ def make_distribution_no_version(tmpdir, basename):
244246

245247
dists = list(pkg_resources.distributions_from_metadata(dist_dir))
246248
assert len(dists) == 1
247-
dist, = dists
249+
(dist,) = dists
248250

249251
return dist, dist_dir
250252

@@ -261,16 +263,17 @@ def make_distribution_no_version(tmpdir, basename):
261263
reason="https://github.com/python/cpython/issues/103632",
262264
)
263265
def test_distribution_version_missing(
264-
tmpdir, suffix, expected_filename, expected_dist_type):
266+
tmpdir, suffix, expected_filename, expected_dist_type
267+
):
265268
"""
266269
Test Distribution.version when the "Version" header is missing.
267270
"""
268271
basename = 'foo.{}'.format(suffix)
269272
dist, dist_dir = make_distribution_no_version(tmpdir, basename)
270273

271-
expected_text = (
272-
"Missing 'Version:' header and/or {} file at path: "
273-
).format(expected_filename)
274+
expected_text = ("Missing 'Version:' header and/or {} file at path: ").format(
275+
expected_filename
276+
)
274277
metadata_path = os.path.join(dist_dir, expected_filename)
275278

276279
# Now check the exception raised when the "version" attribute is accessed.
@@ -307,8 +310,7 @@ def test_distribution_version_missing_undetected_path():
307310

308311
msg, dist = excinfo.value.args
309312
expected = (
310-
"Missing 'Version:' header and/or PKG-INFO file at path: "
311-
'[could not detect]'
313+
"Missing 'Version:' header and/or PKG-INFO file at path: " '[could not detect]'
312314
)
313315
assert msg == expected
314316

@@ -335,10 +337,7 @@ class Environment(str):
335337
env = Environment(tmpdir)
336338
tmpdir.chmod(stat.S_IRWXU)
337339
subs = 'home', 'lib', 'scripts', 'data', 'egg-base'
338-
env.paths = dict(
339-
(dirname, str(tmpdir / dirname))
340-
for dirname in subs
341-
)
340+
env.paths = dict((dirname, str(tmpdir / dirname)) for dirname in subs)
342341
list(map(os.mkdir, env.paths.values()))
343342
return env
344343

@@ -395,8 +394,7 @@ def test_normalize_path_trailing_sep(self, unnormalized, normalized):
395394
],
396395
)
397396
def test_normalize_path_normcase(self, unnormalized, normalized):
398-
"""Ensure mixed case is normalized on case-insensitive filesystems.
399-
"""
397+
"""Ensure mixed case is normalized on case-insensitive filesystems."""
400398
result_from_unnormalized = pkg_resources.normalize_path(unnormalized)
401399
result_from_normalized = pkg_resources.normalize_path(normalized)
402400
assert result_from_unnormalized == result_from_normalized
@@ -414,7 +412,6 @@ def test_normalize_path_normcase(self, unnormalized, normalized):
414412
],
415413
)
416414
def test_normalize_path_backslash_sep(self, unnormalized, expected):
417-
"""Ensure path seps are cleaned on backslash path sep systems.
418-
"""
415+
"""Ensure path seps are cleaned on backslash path sep systems."""
419416
result = pkg_resources.normalize_path(unnormalized)
420417
assert result.endswith(expected)

0 commit comments

Comments
 (0)