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

AIE-3321 fix importlib resources deprecation warnings #19

Merged

Conversation

jclerman
Copy link
Collaborator

@jclerman jclerman commented Dec 5, 2024

Resolving importlib.resources warnings

Tests and usage of philters_lite generates warnings due to usage of deprecated interfaces from importlib.resources. To wit:

philter_lite/filters/filter_db.py:15
  /Users/jclerman/git/philter-lite/philter_lite/filters/filter_db.py:15: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    return tomllib.loads(resources.read_text(filters, "regex.toml"))

../../.pyenv/versions/3.11.10/lib/python3.11/importlib/resources/_legacy.py:80
minor linting fix
../../.pyenv/versions/3.11.10/lib/python3.11/importlib/resources/_legacy.py:80
../../.pyenv/versions/3.11.10/lib/python3.11/importlib/resources/_legacy.py:80
  /Users/jclerman/.pyenv/versions/3.11.10/lib/python3.11/importlib/resources/_legacy.py:80: 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.
    with open_text(package, resource, encoding, errors) as fp:

philter_lite/filters/filter_db.py:19
  /Users/jclerman/git/philter-lite/philter_lite/filters/filter_db.py:19: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    return tomllib.loads(resources.read_text(filters, "regex_context.toml"))

philter_lite/filters/filter_db.py:23
  /Users/jclerman/git/philter-lite/philter_lite/filters/filter_db.py:23: DeprecationWarning: read_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    return tomllib.loads(resources.read_text(filters, "set.toml"))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

Here, switching to usage of the new interface to resolve those warnings (and avoid use of a deprecated interface).

@jclerman jclerman self-assigned this Dec 5, 2024
@jclerman jclerman requested review from msoedov and kenshih December 5, 2024 19:53
poetry.lock Show resolved Hide resolved
@jclerman jclerman merged commit d454cad into master Dec 5, 2024
4 checks passed
@jclerman jclerman deleted the AIE-3321-fix-importlib-resources-deprecation-warnings branch December 5, 2024 22:02
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

Successfully merging this pull request may close these issues.

2 participants