Skip to content

Commit c7084ee

Browse files
authored
Merge pull request #56 from keshav-space/main
Add black codestyle test for skeleton
2 parents 70a2d2f + 840ccef commit c7084ee

File tree

5 files changed

+44
-5
lines changed

5 files changed

+44
-5
lines changed

etc/scripts/fix_thirdparty.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def fix_thirdparty_dir(
7878
package_envts_not_fetched = utils_thirdparty.fetch_missing_wheels(dest_dir=thirdparty_dir)
7979
print("***FETCH*** MISSING SOURCES")
8080
src_name_ver_not_fetched = utils_thirdparty.fetch_missing_sources(dest_dir=thirdparty_dir)
81-
81+
8282
package_envts_not_built = []
8383
if build_wheels:
8484
print("***BUILD*** MISSING WHEELS")
@@ -89,7 +89,7 @@ def fix_thirdparty_dir(
8989
dest_dir=thirdparty_dir,
9090
)
9191
package_envts_not_built, _wheel_filenames_built = results
92-
92+
9393
print("***ADD*** ABOUT AND LICENSES")
9494
utils_thirdparty.add_fetch_or_update_about_and_license_files(
9595
dest_dir=thirdparty_dir,
@@ -99,7 +99,7 @@ def fix_thirdparty_dir(
9999
# report issues
100100
for name, version in src_name_ver_not_fetched:
101101
print(f"{name}=={version}: Failed to fetch source distribution.")
102-
102+
103103
for package, envt in package_envts_not_built:
104104
print(
105105
f"{package.name}=={package.version}: Failed to build wheel "

etc/scripts/utils_requirements.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def has_ops(l):
8686
return any(op in l for op in ops)
8787

8888
if not has_ops:
89-
return line
89+
return line
9090

9191
splitter = re.compile(r"[><!=~;, \[\]]+").split
9292
return splitter(line)[0]

etc/scripts/utils_thirdparty.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,14 @@
9797
"310": "3.10",
9898
}
9999

100+
100101
def get_python_dot_version(version):
101102
"""
102103
Return a dot version from a plain, non-dot version.
103104
"""
104105
return PYTHON_DOT_VERSIONS_BY_VER[version]
105106

107+
106108
ABIS_BY_PYTHON_VERSION = {
107109
"36": ["cp36", "cp36m"],
108110
"37": ["cp37", "cp37m"],
@@ -2529,7 +2531,7 @@ def hash_requirements(dest_dir=THIRDPARTY_DIR, requirements_file="requirements.t
25292531

25302532

25312533
def add_fetch_or_update_about_and_license_files(
2532-
dest_dir=THIRDPARTY_DIR,
2534+
dest_dir=THIRDPARTY_DIR,
25332535
include_remote=True,
25342536
strip_classifiers=False,
25352537
):

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ where=src
3939
testing =
4040
pytest >= 6, != 7.0.0
4141
pytest-xdist >= 2
42+
black
4243
docs=
4344
Sphinx>=3.3.1
4445
sphinx-rtd-theme>=0.5.0

tests/test_skeleton_codestyle.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# ScanCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/skeleton for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#
9+
10+
import subprocess
11+
import unittest
12+
import configparser
13+
14+
15+
class BaseTests(unittest.TestCase):
16+
def test_skeleton_codestyle(self):
17+
"""
18+
This test shouldn't run in proliferated repositories.
19+
"""
20+
setup_cfg = configparser.ConfigParser()
21+
setup_cfg.read("setup.cfg")
22+
if setup_cfg["metadata"]["name"] != "skeleton":
23+
return
24+
25+
args = "venv/bin/black --check -l 100 setup.py etc tests"
26+
try:
27+
subprocess.check_output(args.split())
28+
except subprocess.CalledProcessError as e:
29+
print("===========================================================")
30+
print(e.output)
31+
print("===========================================================")
32+
raise Exception(
33+
"Black style check failed; please format the code using:\n"
34+
" python -m black -l 100 setup.py etc tests",
35+
e.output,
36+
) from e

0 commit comments

Comments
 (0)