diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f0f1a089..805ce058 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: - test_requirements.txt - repo: https://github.com/psf/black - rev: 24.3.0 + rev: 24.4.0 hooks: - id: black language_version: python3 @@ -31,7 +31,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.5 + rev: v0.3.7 hooks: - id: ruff diff --git a/compliance_checker/suite.py b/compliance_checker/suite.py index 7d922110..d261a1cc 100644 --- a/compliance_checker/suite.py +++ b/compliance_checker/suite.py @@ -17,13 +17,13 @@ from pathlib import Path from urllib.parse import urlparse +import importlib_metadata import requests from lxml import etree as ET from netCDF4 import Dataset from owslib.sos import SensorObservationService from owslib.swe.sensor.sml import SensorML from packaging.version import parse -from pkg_resources import working_set from compliance_checker import __version__, tempnc from compliance_checker.base import BaseCheck, GenericFile, Result, fix_return_value @@ -73,8 +73,10 @@ def _get_generator_plugins(cls): """ if not hasattr(cls, "suite_generators"): - gens = working_set.iter_entry_points("compliance_checker.generators") - cls.suite_generators = [x.resolve() for x in gens] + gens = importlib_metadata.entry_points( + groups="compliance_checker.generators", + ) + cls.suite_generators = [x.load() for x in gens] return cls.suite_generators @@ -136,7 +138,9 @@ def load_all_available_checkers(cls): Helper method to retrieve all sub checker classes derived from various base classes. """ - cls._load_checkers(working_set.iter_entry_points("compliance_checker.suites")) + cls._load_checkers( + importlib_metadata.entry_points(group="compliance_checker.suites"), + ) @classmethod def _load_checkers(cls, checkers): @@ -147,7 +151,7 @@ def _load_checkers(cls, checkers): for c in checkers: try: - check_obj = c.resolve() + check_obj = c.load() if hasattr(check_obj, "_cc_spec") and hasattr( check_obj, "_cc_spec_version", diff --git a/compliance_checker/tests/test_cli.py b/compliance_checker/tests/test_cli.py index fc6b4f94..c86cd897 100644 --- a/compliance_checker/tests/test_cli.py +++ b/compliance_checker/tests/test_cli.py @@ -91,7 +91,7 @@ def checker_1(): def checker_2(): return Namespace(_cc_spec="checker_2", _cc_spec_version="2.2") - mock_checkers = [Namespace(resolve=checker_1), Namespace(resolve=checker_2)] + mock_checkers = [Namespace(load=checker_1), Namespace(load=checker_2)] with pytest.warns(DeprecationWarning): CheckSuite._load_checkers(mock_checkers) diff --git a/requirements.txt b/requirements.txt index 6277c633..fd3bbe9a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ cf-units>=2 cftime>=1.1.0 +importlib-metadata # drop this when dropping Python 3.8 importlib-resources # drop this when dropping Python 3.8 isodate>=0.6.1 jinja2>=2.7.3