Skip to content

Commit

Permalink
Replace pkg_resources with importlib_resources (#562)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Doggart <10991724+peter-doggart@users.noreply.github.com>
  • Loading branch information
foarsitter and peter-doggart authored Sep 24, 2023
1 parent 289de36 commit 7ce0ef8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit 7ce0ef8

Please sign in to comment.