guessit-io / guessit

GuessIt is a python library that extracts as much information as possible from a video filename.
https://guessit-io.github.io/guessit
GNU Lesser General Public License v3.0
814 stars 92 forks source link

fix(packaging): use stdlib importlib.resources in py 3.7+ #715

Closed mgorny closed 2 years ago

mgorny commented 2 years ago

importlib.resources is available as a stdlib module since Python 3.7. Use that if it's available, and fall back to the external importlib_resources back for Python < 3.7.

codecov-commenter commented 2 years ago

Codecov Report

Merging #715 (ca4bec6) into develop (de85403) will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #715   +/-   ##
========================================
  Coverage    98.49%   98.49%           
========================================
  Files           52       52           
  Lines         3387     3393    +6     
========================================
+ Hits          3336     3342    +6     
  Misses          51       51           
Impacted Files Coverage Δ
guessit/options.py 97.93% <100.00%> (+0.04%) :arrow_up:
guessit/rules/properties/website.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7044af3...ca4bec6. Read the comment docs.

plotski commented 2 years ago

You might want to switch to the new files() API. open_text() and read_text() are deprecated in importlib_resources >= 5.3.0.

This might not be an issue with importlib.resources in the standard library, but Python 3.6 users are getting deprecation warnings.

https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy https://importlib-resources.readthedocs.io/en/latest/history.html https://docs.python.org/3/library/importlib.html#module-importlib.resources

mgorny commented 2 years ago

Shouldn't these methods be at least documented as deprecated in the stdlib then?

plotski commented 2 years ago

I don't know. Three days ago I didn't even know importlib_resources existed. :)

I'm not really worried guessit will stop working soon with Python 3.6, but the warnings are annoying and using deprecated APIs should be avoided in general.