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

Support Python 3.12 #165

Merged
merged 1 commit into from
Nov 17, 2023
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: 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")
)