alisaifee / limits

Rate limiting using various strategies and storage backends such as redis & memcached
https://limits.readthedocs.org
MIT License
423 stars 58 forks source link

Fix usage of `importlib_resources` for Python >= 3.7 #184

Closed penguinpee closed 11 months ago

penguinpee commented 1 year ago

importlib.resources is part of the Python standard library since Python 3.7:

https://docs.python.org/3/library/importlib.resources.html

Make sure limits is compatible with Python >= 3.7.

codecov[bot] commented 1 year ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (ada96bb) 96.58% compared to head (ba93be6) 96.59%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #184 +/- ## ======================================= Coverage 96.58% 96.59% ======================================= Files 25 25 Lines 1173 1176 +3 Branches 127 127 ======================================= + Hits 1133 1136 +3 Misses 20 20 Partials 20 20 ``` | [Files](https://app.codecov.io/gh/alisaifee/limits/pull/184?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ali-Akber+Saifee) | Coverage Δ | | |---|---|---| | [limits/util.py](https://app.codecov.io/gh/alisaifee/limits/pull/184?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ali-Akber+Saifee#diff-bGltaXRzL3V0aWwucHk=) | `98.78% <100.00%> (+0.04%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

alisaifee commented 1 year ago

Python 3.7 support was actually dropped recently so the conditional import & dependency could just be removed altogether

penguinpee commented 1 year ago

Python 3.7 support was actually dropped recently so the conditional import & dependency could just be removed altogether

That's up to you, really. In Fedora all currently supported releases are Python >= 3.11.

Removing it, though, will break older Python releases. Whereas the patch, as is, is backward compatible.

alisaifee commented 11 months ago

Closing in favor of d9a8fba0616f6736c845a156e669b7d1e13cbd86

alisaifee commented 11 months ago

Actually it looks like importlib.resources.files is only available in python 3.9 and conditionally handling that in code is more effort than I think it's worth. Once python 3.8 is EOL I can remove this.