Skip to content

Commit

Permalink
Merge pull request #56 from keshav-space/main
Browse files Browse the repository at this point in the history
Add black codestyle test for skeleton
  • Loading branch information
pombredanne authored Feb 23, 2022
2 parents 70a2d2f + 840ccef commit c7084ee
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 5 deletions.
6 changes: 3 additions & 3 deletions etc/scripts/fix_thirdparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def fix_thirdparty_dir(
package_envts_not_fetched = utils_thirdparty.fetch_missing_wheels(dest_dir=thirdparty_dir)
print("***FETCH*** MISSING SOURCES")
src_name_ver_not_fetched = utils_thirdparty.fetch_missing_sources(dest_dir=thirdparty_dir)

package_envts_not_built = []
if build_wheels:
print("***BUILD*** MISSING WHEELS")
Expand All @@ -89,7 +89,7 @@ def fix_thirdparty_dir(
dest_dir=thirdparty_dir,
)
package_envts_not_built, _wheel_filenames_built = results

print("***ADD*** ABOUT AND LICENSES")
utils_thirdparty.add_fetch_or_update_about_and_license_files(
dest_dir=thirdparty_dir,
Expand All @@ -99,7 +99,7 @@ def fix_thirdparty_dir(
# report issues
for name, version in src_name_ver_not_fetched:
print(f"{name}=={version}: Failed to fetch source distribution.")

for package, envt in package_envts_not_built:
print(
f"{package.name}=={package.version}: Failed to build wheel "
Expand Down
2 changes: 1 addition & 1 deletion etc/scripts/utils_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def has_ops(l):
return any(op in l for op in ops)

if not has_ops:
return line
return line

splitter = re.compile(r"[><!=~;, \[\]]+").split
return splitter(line)[0]
Expand Down
4 changes: 3 additions & 1 deletion etc/scripts/utils_thirdparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@
"310": "3.10",
}


def get_python_dot_version(version):
"""
Return a dot version from a plain, non-dot version.
"""
return PYTHON_DOT_VERSIONS_BY_VER[version]


ABIS_BY_PYTHON_VERSION = {
"36": ["cp36", "cp36m"],
"37": ["cp37", "cp37m"],
Expand Down Expand Up @@ -2529,7 +2531,7 @@ def hash_requirements(dest_dir=THIRDPARTY_DIR, requirements_file="requirements.t


def add_fetch_or_update_about_and_license_files(
dest_dir=THIRDPARTY_DIR,
dest_dir=THIRDPARTY_DIR,
include_remote=True,
strip_classifiers=False,
):
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ where=src
testing =
pytest >= 6, != 7.0.0
pytest-xdist >= 2
black
docs=
Sphinx>=3.3.1
sphinx-rtd-theme>=0.5.0
Expand Down
36 changes: 36 additions & 0 deletions tests/test_skeleton_codestyle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/skeleton for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

import subprocess
import unittest
import configparser


class BaseTests(unittest.TestCase):
def test_skeleton_codestyle(self):
"""
This test shouldn't run in proliferated repositories.
"""
setup_cfg = configparser.ConfigParser()
setup_cfg.read("setup.cfg")
if setup_cfg["metadata"]["name"] != "skeleton":
return

args = "venv/bin/black --check -l 100 setup.py etc tests"
try:
subprocess.check_output(args.split())
except subprocess.CalledProcessError as e:
print("===========================================================")
print(e.output)
print("===========================================================")
raise Exception(
"Black style check failed; please format the code using:\n"
" python -m black -l 100 setup.py etc tests",
e.output,
) from e

0 comments on commit c7084ee

Please sign in to comment.