Fix 'importlib.abc.TraversableResources' deprecation warning in Python 3.12 (#10452)

This commit is contained in:
Hugo van Kemenade 2022-10-31 17:49:51 +02:00 committed by GitHub
parent 8e2de91bf8
commit 0314b50c52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix 'importlib.abc.TraversableResources' deprecation warning in Python 3.12.

View File

@ -275,7 +275,12 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
def get_resource_reader(self, name: str) -> importlib.abc.TraversableResources: # type: ignore if sys.version_info >= (3, 12):
from importlib.resources.abc import TraversableResources
else:
from importlib.abc import TraversableResources
def get_resource_reader(self, name: str) -> TraversableResources: # type: ignore
if sys.version_info < (3, 11): if sys.version_info < (3, 11):
from importlib.readers import FileReader from importlib.readers import FileReader
else: else:

View File

@ -9,6 +9,7 @@ envlist =
py39 py39
py310 py310
py311 py311
py312
pypy3 pypy3
py37-{pexpect,xdist,unittestextras,numpy,pluggymain,pylib} py37-{pexpect,xdist,unittestextras,numpy,pluggymain,pylib}
doctesting doctesting