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

'importlib.abc.Traversable' is deprecated and slated for removal in Python 3.14 #158

Closed
jose-reveni opened this issue Oct 16, 2023 · 5 comments

Comments

@jose-reveni
Copy link
Contributor

Deprecated since version 3.12, will be removed in version 3.14: Use importlib.resources.abc.TraversableResources instead.

@mdomke
Copy link
Owner

mdomke commented Oct 24, 2023

Thanks for the heads-up. However, we have to consider compatibility with older versions (at least Python 3.8, which is still supported until end of 2024). Do you actually mean importlib.resources.abc.Traversable? Feel free to add a conditional import to schwifty.registry to be forward compatible with upcoming versions!

@Natim
Copy link
Contributor

Natim commented Nov 28, 2023

I deep dived into this, apparently what has been deprecated is not the Traversable type but the ResourceReader type. @jose-reveni can you confirm that we don't need to do anything more here?

@yezz123
Copy link

yezz123 commented Jan 9, 2024

Hey @Natim @mdomke coming for same error i'm facing here https://github.com/pydantic/pydantic-extra-types/actions/runs/7455350706/job/20284285629?pr=65 is there a way to support from importlib_resources.abc import Traversable this to run because it's throwing same error:

PR: pydantic/pydantic-extra-types#65

__________________ ERROR collecting tests/test_json_schema.py __________________
tests/test_json_schema.py:12: in <module>
    from pydantic_extra_types.iban import Iban
pydantic_extra_types/iban.py:14: in <module>
    import schwifty
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/schwifty/__init__.py:6: in <module>
    from schwifty.bic import BIC
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/schwifty/bic.py:14: in <module>
    from schwifty import registry
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/schwifty/registry.py:14: in <module>
    from importlib.abc import Traversable
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/abc.py:35: in __getattr__
    warnings._deprecated(f"{__name__}.{name}", remove=(3, 14))
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/warnings.py:529: in _deprecated
    warn(msg, DeprecationWarning, stacklevel=3)
E   DeprecationWarning: 'importlib.abc.Traversable' is deprecated and slated for removal in Python 3.14
!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!

@mdomke
Copy link
Owner

mdomke commented Jan 9, 2024

@yezz123 Why exactly do your tests fail for a DeprecationWarning that informs about the removal of a type in a Python version that's not expected to surface before 2025? I can however try to find a backwards compatible solution that makes this warning go away.

@jose-reveni
Copy link
Contributor Author

I deep dived into this, apparently what has been deprecated is not the Traversable type but the ResourceReader type. @jose-reveni can you confirm that we don't need to do anything more here?

Hey sorry I took so long to retry. I'm pretty sure I meant importlib.abc.Traversable, because back when I wrote this I copied the warning I got.
I also see that it was deprecated in 3.12 https://docs.python.org/3.12/whatsnew/3.12.html#deprecated

Anyways, #183 actually fixed this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants