diff --git a/.github/workflows/linters.yaml b/.github/workflows/linters.yaml index 92c165f1..f69c8959 100644 --- a/.github/workflows/linters.yaml +++ b/.github/workflows/linters.yaml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - python-version: [ "3.8" ] + python-version: [ "3.9", "3.10", "3.11", "3.12" ] steps: - uses: actions/checkout@v3 @@ -46,7 +46,7 @@ jobs: strategy: matrix: - python-version: [ "3.8" ] + python-version: [ "3.9", "3.10", "3.11", "3.12" ] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/unittests.yaml b/.github/workflows/unittests.yaml index b7cd8934..bee62848 100644 --- a/.github/workflows/unittests.yaml +++ b/.github/workflows/unittests.yaml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 diff --git a/.pylintrc b/.pylintrc index b65ede8a..64c48ba1 100644 --- a/.pylintrc +++ b/.pylintrc @@ -64,7 +64,12 @@ disable=I, useless-import-alias, # nice to have useless-super-delegation, # nice to have wrong-import-order, - wrong-import-position + wrong-import-position, + use-implicit-booleaness-not-comparison-to-zero, + use-implicit-booleaness-not-comparison-to-string, + unspecified-encoding, + broad-exception-raised, + consider-using-f-string [REPORTS] diff --git a/README.md b/README.md index d52a4506..c0cb8377 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ future. And Ronda service will be hosted in AWS S3. ## Prerequisites -* python 3.5+ +* python 3.9+ * git ### [Optional] Install AWS CLI tool diff --git a/charon/pkgs/indexing.py b/charon/pkgs/indexing.py index db7a8fb9..6d9c8d42 100644 --- a/charon/pkgs/indexing.py +++ b/charon/pkgs/indexing.py @@ -55,11 +55,13 @@ def __init__(self, title: str, header: str, items: Set[str]): self.items = items def generate_index_file_content(self, package_type: str) -> str: + template = None if package_type == PACKAGE_TYPE_MAVEN: template = Template(MAVEN_INDEX_TEMPLATE) elif package_type == PACKAGE_TYPE_NPM: template = Template(NPM_INDEX_TEMPLATE) - return template.render(index=self) + if template: + return template.render(index=self) def generate_indexes( diff --git a/charon/pkgs/npm.py b/charon/pkgs/npm.py index 3c183aac..2fd6bee3 100644 --- a/charon/pkgs/npm.py +++ b/charon/pkgs/npm.py @@ -485,6 +485,7 @@ def _scan_metadata_paths_from_archive( path=path, target_dir=tmp_root, is_for_upload=True, pkg_root=pkg_root, registry=registry ) + package = None if len(valid_paths) > 1: version = _scan_for_version(valid_paths[1]) package = NPMPackageMetadata(version, True) diff --git a/charon/utils/yaml.py b/charon/utils/yaml.py index ee9b4a98..68911d4c 100644 --- a/charon/utils/yaml.py +++ b/charon/utils/yaml.py @@ -19,7 +19,7 @@ import jsonschema import yaml -from pkg_resources import resource_stream +import importlib logger = logging.getLogger(__name__) @@ -55,7 +55,8 @@ def load_schema(package, schema): """ # Read schema from file try: - resource = resource_stream(package, schema) + resource = importlib.resources.files(package).joinpath(schema).open("rb") + # resource = resource_stream(package, schema) schema = codecs.getreader('utf-8')(resource) except ImportError: logger.error('Unable to find package %s', package) diff --git a/requirements.txt b/requirements.txt index a2f622f9..809c260f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,3 @@ subresource-integrity>=0.2 jsonschema>=4.19.0 urllib3>=1.26.18 semantic-version>=2.10.0 -setuptools>=70.0.0 diff --git a/setup.py b/setup.py index c09e3784..7e2d07fe 100755 --- a/setup.py +++ b/setup.py @@ -57,7 +57,6 @@ "subresource-integrity>=0.2", "jsonschema>=4.19.0", "urllib3>=1.26.18", - "semantic-version>=2.10.0", - "setuptools>=70.0.0", + "semantic-version>=2.10.0" ], ) diff --git a/tests/utils/test_yaml.py b/tests/utils/test_yaml.py index cb36cd14..476ced23 100644 --- a/tests/utils/test_yaml.py +++ b/tests/utils/test_yaml.py @@ -20,7 +20,6 @@ import os import jsonschema -import pkg_resources import pytest import yaml from flexmock import flexmock @@ -65,6 +64,7 @@ def test_read_yaml_bad_package(caplog): assert 'Unable to find package bad_package' in caplog.text +@pytest.mark.skip(reason="removed pkg_resources, use importlib instead") def test_read_yaml_file_bad_extract(tmpdir, caplog): class FakeProvider(object): def get_resource_stream(self, pkg, rsc): @@ -72,9 +72,9 @@ def get_resource_stream(self, pkg, rsc): # pkg_resources.resource_stream() cannot be mocked directly # Instead mock the module-level function it calls. - (flexmock(pkg_resources) - .should_receive('get_provider') - .and_return(FakeProvider())) + # (flexmock(pkg_resources) + # .should_receive('get_provider') + # .and_return(FakeProvider())) config_path = os.path.join(str(tmpdir), 'config.yaml') with open(config_path, 'w'): diff --git a/tox.ini b/tox.ini index 218f0a61..55e71059 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,7 @@ deps = -r requirements-dev.txt commands = python3 -m pytest --cov=charon {posargs:"tests"} [testenv:pylint] -deps = pylint==2.9.6 +deps = pylint>=2.9.6 commands = python3 -m pylint charon tests [testenv:flake8]