Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed last of pkg_resources. #1060

Merged
merged 5 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
14 changes: 9 additions & 5 deletions compliance_checker/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,8 +73,10 @@
"""

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(

Check warning on line 76 in compliance_checker/suite.py

View check run for this annotation

Codecov / codecov/patch

compliance_checker/suite.py#L76

Added line #L76 was not covered by tests
groups="compliance_checker.generators",
)
cls.suite_generators = [x.load() for x in gens]

Check warning on line 79 in compliance_checker/suite.py

View check run for this annotation

Codecov / codecov/patch

compliance_checker/suite.py#L79

Added line #L79 was not covered by tests

return cls.suite_generators

Expand Down Expand Up @@ -136,7 +138,9 @@
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):
Expand All @@ -147,7 +151,7 @@

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",
Expand Down
2 changes: 1 addition & 1 deletion compliance_checker/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down