Skip to content

Commit fae097a

Browse files
authored
Merge pull request #155 from p1c2u/feature/use-importlib_resources-instead-of-pkg_resources
use importlib_resources instead of pkg_resources
2 parents 12f6b39 + 4532fc4 commit fae097a

File tree

3 files changed

+55
-57
lines changed

3 files changed

+55
-57
lines changed

openapi_spec_validator/schemas.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
"""OpenAIP spec validator schemas module."""
22
import os
33

4-
from pkg_resources import resource_filename
54
import urllib.parse
65
import urllib.request
76
from yaml import load
87

8+
import importlib_resources
99
from openapi_spec_validator.loaders import ExtendedSafeLoader
1010

1111

1212
def get_openapi_schema(version):
1313
path = 'resources/schemas/v{0}/schema.json'.format(version)
14-
path_resource = resource_filename('openapi_spec_validator', path)
15-
path_full = os.path.join(os.path.dirname(__file__), path_resource)
14+
ref = importlib_resources.files('openapi_spec_validator') / path
15+
with importlib_resources.as_file(ref) as path_resource:
16+
path_full = os.path.join(os.path.dirname(__file__), path_resource)
1617
schema = read_yaml_file(path_full)
1718
schema_url = urllib.parse.urljoin('file:', urllib.request.pathname2url(path_full))
1819
return schema, schema_url

poetry.lock

+50-53
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ openapi-schema-validator = {version = "^0.3.0a1", allow-prereleases = true}
3737
python = "^3.7.0"
3838
PyYAML = ">=5.1"
3939
requests = {version = "*", optional = true}
40-
setuptools = "^60.9.3"
40+
importlib-resources = "^5.8.0"
4141

4242
[tool.poetry.extras]
4343
dev = ["pre-commit"]

0 commit comments

Comments
 (0)