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

Replace pkg_resources with importlib_resources #562

Merged
merged 2 commits into from
Sep 24, 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
8 changes: 5 additions & 3 deletions flask_restx/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"""
import io
import json
import pkg_resources

import importlib_resources

from collections.abc import Mapping
from jsonschema import Draft4Validator
Expand Down Expand Up @@ -56,8 +57,9 @@ def __init__(self, filename, validator=Draft4Validator):

def _load(self):
if not self._schema:
filename = pkg_resources.resource_filename(__name__, self.filename)
with io.open(filename) as infile:
ref = importlib_resources.files(__name__) / self.filename

with io.open(ref) as infile:
self._schema = json.load(infile)

def __getitem__(self, key):
Expand Down
1 change: 1 addition & 0 deletions requirements/install.pip
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ jsonschema
Flask>=0.8, !=2.0.0
werkzeug !=2.0.0
pytz
importlib_resources
Loading