Skip to content

Commit 3bb9040

Browse files
committed
use importlib_resources instead of pkg_resources
1 parent 12f6b39 commit 3bb9040

File tree

3 files changed

+55
-56
lines changed

3 files changed

+55
-56
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
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ python = "^3.7.0"
3838
PyYAML = ">=5.1"
3939
requests = {version = "*", optional = true}
4040
setuptools = "^60.9.3"
41+
importlib-resources = "^5.8.0"
4142

4243
[tool.poetry.extras]
4344
dev = ["pre-commit"]

0 commit comments

Comments
 (0)