Skip to content

Commit d05665a

Browse files
committed
Apply cosmetic refactorings
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 092f545 commit d05665a

11 files changed

+40
-39
lines changed

docs/source/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
html_show_sphinx = True
9595

9696
# Define CSS and HTML abbreviations used in .rst files. These are examples.
97-
# .. role:: is used to refer to styles defined in _static/theme_overrides.css and is used like this: :red:`text`
97+
# .. role:: is used to refer to styles defined in _static/theme_overrides.css
98+
# and is used like this: :red:`text`
9899
rst_prolog = """
99100
.. |psf| replace:: Python Software Foundation
100101

etc/scripts/check_thirdparty.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
#
43
# Copyright (c) nexB Inc. and others. All rights reserved.
54
# ScanCode is a trademark of nexB Inc.
@@ -41,8 +40,7 @@ def check_thirdparty_dir(
4140
"""
4241
Check a thirdparty directory for problems and print these on screen.
4342
"""
44-
# check for problems
45-
print(f"==> CHECK FOR PROBLEMS")
43+
print("==> CHECK FOR PROBLEMS")
4644
utils_thirdparty.find_problems(
4745
dest_dir=dest,
4846
report_missing_sources=sdists,

etc/scripts/fetch_thirdparty.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
#
43
# Copyright (c) nexB Inc. and others. All rights reserved.
54
# ScanCode is a trademark of nexB Inc.
@@ -10,7 +9,6 @@
109
#
1110

1211
import itertools
13-
import os
1412
import sys
1513
from collections import defaultdict
1614

@@ -109,7 +107,8 @@
109107
@click.option(
110108
"--use-cached-index",
111109
is_flag=True,
112-
help="Use on disk cached PyPI indexes list of packages and versions and do not refetch if present.",
110+
help="Use on disk cached PyPI indexes list of packages and versions and "
111+
"do not refetch if present.",
113112
)
114113
@click.option(
115114
"--sdist-only",
@@ -261,7 +260,7 @@ def fetch_thirdparty(
261260
if not fetched:
262261
wheels_or_sdist_not_found[f"{name}=={version}"].append(environment)
263262
if TRACE:
264-
print(f" NOT FOUND")
263+
print(" NOT FOUND")
265264

266265
if sdists or (f"{name}=={version}" in wheels_or_sdist_not_found and name in sdist_only):
267266
if TRACE:
@@ -276,17 +275,17 @@ def fetch_thirdparty(
276275
if not fetched:
277276
wheels_or_sdist_not_found[f"{name}=={version}"].append("sdist")
278277
if TRACE:
279-
print(f" NOT FOUND")
278+
print(" NOT FOUND")
280279

281280
mia = []
282281
for nv, dists in wheels_or_sdist_not_found.items():
283282
name, _, version = nv.partition("==")
284283
if name in no_dist:
285284
continue
286-
sdist_missing = sdists and "sdist" in dists and not name in wheel_only
285+
sdist_missing = sdists and "sdist" in dists and name not in wheel_only
287286
if sdist_missing:
288287
mia.append(f"SDist missing: {nv} {dists}")
289-
wheels_missing = wheels and any(d for d in dists if d != "sdist") and not name in sdist_only
288+
wheels_missing = wheels and any(d for d in dists if d != "sdist") and name not in sdist_only
290289
if wheels_missing:
291290
mia.append(f"Wheels missing: {nv} {dists}")
292291

@@ -295,12 +294,12 @@ def fetch_thirdparty(
295294
print(m)
296295
raise Exception(mia)
297296

298-
print(f"==> FETCHING OR CREATING ABOUT AND LICENSE FILES")
297+
print("==> FETCHING OR CREATING ABOUT AND LICENSE FILES")
299298
utils_thirdparty.fetch_abouts_and_licenses(dest_dir=dest_dir, use_cached_index=use_cached_index)
300299
utils_thirdparty.clean_about_files(dest_dir=dest_dir)
301300

302301
# check for problems
303-
print(f"==> CHECK FOR PROBLEMS")
302+
print("==> CHECK FOR PROBLEMS")
304303
utils_thirdparty.find_problems(
305304
dest_dir=dest_dir,
306305
report_missing_sources=sdists,

etc/scripts/gen_pypi_simple.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32

43
# SPDX-License-Identifier: BSD-2-Clause-Views AND MIT
54
# Copyright (c) 2010 David Wolever <david@wolever.net>. All rights reserved.
@@ -132,7 +131,7 @@ def build_links_package_index(packages_by_package_name, base_url):
132131
Return an HTML document as string which is a links index of all packages
133132
"""
134133
document = []
135-
header = f"""<!DOCTYPE html>
134+
header = """<!DOCTYPE html>
136135
<html>
137136
<head>
138137
<title>Links for all packages</title>
@@ -177,13 +176,13 @@ def simple_index_entry(self, base_url):
177176

178177
def build_pypi_index(directory, base_url="https://thirdparty.aboutcode.org/pypi"):
179178
"""
180-
Using a ``directory`` directory of wheels and sdists, create the a PyPI
181-
simple directory index at ``directory``/simple/ populated with the proper
182-
PyPI simple index directory structure crafted using symlinks.
179+
Create the a PyPI simple directory index using a ``directory`` directory of wheels and sdists in
180+
the direvctory at ``directory``/simple/ populated with the proper PyPI simple index directory
181+
structure crafted using symlinks.
183182
184-
WARNING: The ``directory``/simple/ directory is removed if it exists.
185-
NOTE: in addition to the a PyPI simple index.html there is also a links.html
186-
index file generated which is suitable to use with pip's --find-links
183+
WARNING: The ``directory``/simple/ directory is removed if it exists. NOTE: in addition to the a
184+
PyPI simple index.html there is also a links.html index file generated which is suitable to use
185+
with pip's --find-links
187186
"""
188187

189188
directory = Path(directory)

etc/scripts/gen_requirements.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
#
43
# Copyright (c) nexB Inc. and others. All rights reserved.
54
# ScanCode is a trademark of nexB Inc.
@@ -34,7 +33,8 @@ def gen_requirements():
3433
type=pathlib.Path,
3534
required=True,
3635
metavar="DIR",
37-
help="Path to the 'site-packages' directory where wheels are installed such as lib/python3.6/site-packages",
36+
help="Path to the 'site-packages' directory where wheels are installed "
37+
"such as lib/python3.12/site-packages",
3838
)
3939
parser.add_argument(
4040
"-r",

etc/scripts/gen_requirements_dev.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
#
43
# Copyright (c) nexB Inc. and others. All rights reserved.
54
# ScanCode is a trademark of nexB Inc.
@@ -36,7 +35,8 @@ def gen_dev_requirements():
3635
type=pathlib.Path,
3736
required=True,
3837
metavar="DIR",
39-
help='Path to the "site-packages" directory where wheels are installed such as lib/python3.6/site-packages',
38+
help="Path to the 'site-packages' directory where wheels are installed "
39+
"such as lib/python3.12/site-packages",
4040
)
4141
parser.add_argument(
4242
"-d",

etc/scripts/test_utils_pip_compatibility_tags.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""Generate and work with PEP 425 Compatibility Tags.
1+
"""
2+
Generate and work with PEP 425 Compatibility Tags.
23
34
copied from pip-20.3.1 pip/tests/unit/test_utils_compatibility_tags.py
45
download_url: https://raw.githubusercontent.com/pypa/pip/20.3.1/tests/unit/test_utils_compatibility_tags.py
@@ -50,7 +51,7 @@ def test_version_info_to_nodot(version_info, expected):
5051
assert actual == expected
5152

5253

53-
class Testcompatibility_tags(object):
54+
class Testcompatibility_tags:
5455
def mock_get_config_var(self, **kwd):
5556
"""
5657
Patch sysconfig.get_config_var for arbitrary keys.
@@ -81,7 +82,7 @@ def test_no_hyphen_tag(self):
8182
assert "-" not in tag.platform
8283

8384

84-
class TestManylinux2010Tags(object):
85+
class TestManylinux2010Tags:
8586
@pytest.mark.parametrize(
8687
"manylinux2010,manylinux1",
8788
[
@@ -104,7 +105,7 @@ def test_manylinux2010_implies_manylinux1(self, manylinux2010, manylinux1):
104105
assert arches[:2] == [manylinux2010, manylinux1]
105106

106107

107-
class TestManylinux2014Tags(object):
108+
class TestManylinux2014Tags:
108109
@pytest.mark.parametrize(
109110
"manylinuxA,manylinuxB",
110111
[

etc/scripts/utils_dejacode.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
#
43
# Copyright (c) nexB Inc. and others. All rights reserved.
54
# ScanCode is a trademark of nexB Inc.
@@ -25,7 +24,7 @@
2524

2625
DEJACODE_API_URL_PACKAGES = f"{DEJACODE_API_URL}packages/"
2726
DEJACODE_API_HEADERS = {
28-
"Authorization": "Token {}".format(DEJACODE_API_KEY),
27+
"Authorization": f"Token {DEJACODE_API_KEY}",
2928
"Accept": "application/json; indent=4",
3029
}
3130

@@ -50,6 +49,7 @@ def fetch_dejacode_packages(params):
5049
DEJACODE_API_URL_PACKAGES,
5150
params=params,
5251
headers=DEJACODE_API_HEADERS,
52+
timeout=10,
5353
)
5454

5555
return response.json()["results"]
@@ -93,7 +93,7 @@ def update_with_dejacode_about_data(distribution):
9393
if package_data:
9494
package_api_url = package_data["api_url"]
9595
about_url = f"{package_api_url}about"
96-
response = requests.get(about_url, headers=DEJACODE_API_HEADERS)
96+
response = requests.get(about_url, headers=DEJACODE_API_HEADERS, timeout=10)
9797
# note that this is YAML-formatted
9898
about_text = response.json()["about_data"]
9999
about_data = saneyaml.load(about_text)
@@ -113,7 +113,7 @@ def fetch_and_save_about_files(distribution, dest_dir="thirdparty"):
113113
if package_data:
114114
package_api_url = package_data["api_url"]
115115
about_url = f"{package_api_url}about_files"
116-
response = requests.get(about_url, headers=DEJACODE_API_HEADERS)
116+
response = requests.get(about_url, headers=DEJACODE_API_HEADERS, timeout=10)
117117
about_zip = response.content
118118
with io.BytesIO(about_zip) as zf:
119119
with zipfile.ZipFile(zf) as zi:
@@ -201,6 +201,7 @@ def create_dejacode_package(distribution):
201201
DEJACODE_API_URL_PACKAGES,
202202
data=new_package_payload,
203203
headers=DEJACODE_API_HEADERS,
204+
timeout=10,
204205
)
205206
new_package_data = response.json()
206207
if response.status_code != 201:

etc/scripts/utils_pip_compatibility_tags.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""Generate and work with PEP 425 Compatibility Tags.
1+
"""
2+
Generate and work with PEP 425 Compatibility Tags.
23
34
copied from pip-20.3.1 pip/_internal/utils/compatibility_tags.py
45
download_url: https://github.com/pypa/pip/blob/20.3.1/src/pip/_internal/utils/compatibility_tags.py
@@ -130,7 +131,7 @@ def _get_custom_interpreter(implementation=None, version=None):
130131
implementation = interpreter_name()
131132
if version is None:
132133
version = interpreter_version()
133-
return "{}{}".format(implementation, version)
134+
return f"{implementation}{version}"
134135

135136

136137
def get_supported(
@@ -140,7 +141,8 @@ def get_supported(
140141
abis=None, # type: Optional[List[str]]
141142
):
142143
# type: (...) -> List[Tag]
143-
"""Return a list of supported tags for each version specified in
144+
"""
145+
Return a list of supported tags for each version specified in
144146
`versions`.
145147
146148
:param version: a string version, of the form "33" or "32",

etc/scripts/utils_requirements.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
#
43
# Copyright (c) nexB Inc. and others. All rights reserved.
54
# ScanCode is a trademark of nexB Inc.
@@ -40,7 +39,7 @@ def get_required_name_versions(requirement_lines, with_unpinned=False):
4039
req_line = req_line.strip()
4140
if not req_line or req_line.startswith("#"):
4241
continue
43-
if req_line.startswith("-") or (not with_unpinned and not "==" in req_line):
42+
if req_line.startswith("-") or (not with_unpinned and "==" not in req_line):
4443
print(f"Requirement line is not supported: ignored: {req_line}")
4544
continue
4645
yield get_required_name_version(requirement=req_line, with_unpinned=with_unpinned)

0 commit comments

Comments
 (0)