Skip to content

Migrate from Legacy importlib resource import #19

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

Merged
merged 3 commits into from
Mar 23, 2024

Conversation

ColonelPanics
Copy link
Contributor

@ColonelPanics ColonelPanics commented Mar 1, 2024

The current version (1.0.2) returns the following error on mkdocs serve:

INFO    -  DeprecationWarning: path is deprecated. Use files() instead. Refer to
           https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
             File "/opt/homebrew/lib/python3.11/site-packages/mkdocs_spellcheck/backends/symspellpy.py", line 33, in __init__
               with resources.path("symspellpy", "frequency_dictionary_en_82_765.txt") as dictionary_path:
             File
           "/opt/homebrew/Cellar/[email protected]/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/resources/_legacy.py",
           line 18, in wrapper
               warnings.warn(

Some discussion occurred with fixing the deprecation warning in #16 however that doesn't seem to have solved the issue.

Through moving from the legacy import method (as reported in the info message above) to utilising the newer APIs (used this as reference) this method is fixed and spellcheck still seems to work as expected. (Tested by putting in some spelling errors in existing documentation and seeing symspell report them as typos)

Version Used:

  • Python 3.11.8
  • pip 24.0
  • mkdocs 1.5.3
  • mkdocs-spellcheck 1.0.2

@pawamoy
Copy link
Owner

pawamoy commented Mar 1, 2024

Damn, importlib is the most volatile Python package I've ever used. It's full of non-compatible breaking changes across each Python version 😫

As we can see from the quality check, importlib.resources has no attribute files on Python 3.8. Maybe we could use the backported importlib-resources dependency instead?

@ColonelPanics
Copy link
Contributor Author

Apologies! I had somewhat expected it was to do with Python version (which, as you mention, explains why quality CI failed for this).

Sadly I'm not much of an experienced Python developer, maintaining some documentation and making a lot of use of this plugin, so I'm not quite sure what direction is best for addressing these issues!

I've patched my installation locally to remove the output spam so it's at least fixed on my end, happy for this to not necessarily be merged

@pawamoy
Copy link
Owner

pawamoy commented Mar 1, 2024

No worries, I'll take it from there then 🙂
Thank you for bringing this to my attention, and happy to hear this plugin is useful to you 😄

@pawamoy pawamoy self-assigned this Mar 1, 2024
@pawamoy pawamoy merged commit d18a917 into pawamoy:main Mar 23, 2024
16 checks passed
pawamoy added a commit that referenced this pull request Mar 23, 2024
@pawamoy
Copy link
Owner

pawamoy commented Mar 23, 2024

Released as v1.0.3, thanks again for your help 🙂

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