pawamoy / mkdocs-spellcheck

A spell checker plugin for MkDocs.
https://pawamoy.github.io/mkdocs-spellcheck/
ISC License
16 stars 4 forks source link

Migrate from Legacy importlib resource import #19

Closed ColonelPanicks closed 6 months ago

ColonelPanicks commented 7 months ago

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/python@3.11/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:

pawamoy commented 7 months ago

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

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?

ColonelPanicks commented 7 months ago

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 commented 7 months ago

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

pawamoy commented 6 months ago

Released as v1.0.3, thanks again for your help :slightly_smiling_face: