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

Use files() to open *-table JSONs (importlib deprecated open_text) #11

Closed
cardoso-neto opened this issue Jun 2, 2023 · 2 comments
Closed

Comments

@cardoso-neto
Copy link

I'm using python 3.11 and I'm getting these a lot:

> multiformats_config/multicodec.py:80:
>> with importlib_resources.open_text("multiformats_config", "multicodec-table.json", encoding="utf8") as _table_f:
> multiformats_config/multibase.py:53
>> with importlib_resources.open_text("multiformats_config", "multibase-table.json", encoding="utf8") as _table_f:
DeprecationWarning:
    open_text is deprecated. Use files() instead.
    Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.

And since I'm here, let me state that this is the best implementation of the multiformats protocol I've seen and it is only thanks to this package that I was able to get multiformats adopted where I work.

@cardoso-neto
Copy link
Author

cardoso-neto commented Jun 2, 2023

Fix could look like this for multibase.py:

    pkg_dir = importlib_resources.files("multiformats_config")
    # then either joinpath
    with pkg_dir.joinpath("multibase-table.json").open(encoding="utf8") as _table_f:
    # or slash operator
    with (pkg_dir / "multibase-table.json").open(encoding="utf8") as _table_f:

@sg495
Copy link
Contributor

sg495 commented Jun 8, 2023

Thanks for spotting this! (and for the compliment 😊). We've only recently moved to 3.11 ourselves, and this library hasn't yet been migrated. We'll get to it shortly 👍.

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

2 participants