Skip to content

Commit

Permalink
Merge pull request #165 from max-muoto/master
Browse files Browse the repository at this point in the history
Support Python 3.12
  • Loading branch information
ymilki authored Nov 17, 2023
2 parents 10edb95 + d08645a commit 2e54d8a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ jobs:
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand Down
7 changes: 4 additions & 3 deletions swagger_spec_validator/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from urllib.request import urlopen

import yaml
from pkg_resources import resource_filename
import importlib.resources
from typing_extensions import ParamSpec

try:
Expand Down Expand Up @@ -55,8 +55,9 @@ def read_file(file_path: str) -> dict[str, Any]:

@lru_cache()
def read_resource_file(resource_path: str) -> tuple[dict[str, Any], str]:
schema_path = resource_filename("swagger_spec_validator", resource_path)
return read_file(schema_path), schema_path
ref = importlib.resources.files('swagger_spec_validator') / resource_path
with importlib.resources.as_file(ref) as path:
return read_file(path), path


def read_url(url: str, timeout: float = TIMEOUT_SEC) -> dict[str, Any]:
Expand Down
4 changes: 2 additions & 2 deletions tests/common_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import uuid
from unittest import mock

from pkg_resources import resource_filename
import importlib.resources

from swagger_spec_validator.common import read_file
from swagger_spec_validator.common import read_resource_file
Expand All @@ -19,5 +19,5 @@ def test_read_resource_file(monkeypatch):
read_resource_file(resource_path)

m.assert_called_once_with(
resource_filename("swagger_spec_validator", resource_path)
importlib.resources.files("swagger_spec_validator")
)

0 comments on commit 2e54d8a

Please sign in to comment.