llllllllll / slider

Utilities for working with osu! files and data
https://llllllllll.github.io/slider/index.html
GNU Lesser General Public License v3.0
39 stars 17 forks source link

Use importlib.resources instead of deprecated pkg_resources #114

Closed Rubo3 closed 1 year ago

Rubo3 commented 1 year ago

This patch fixes the warnings I get when running the tests, by using importlib.resources.files instead of pkg_resources.resource_filename. All of them pass.

tybug commented 1 year ago

this raises our minimum python version to 3.9 - is there an alternative which is still more modern than pkg_resources? Which I agree needs to go.

Rubo3 commented 1 year ago

Since you look for files in the same directory of the module, what about

from pathlib import Path
...
    return CollectionDB.from_path(Path(__file__).parent / name)

pathlib was introduced in Python 3.4.

tybug commented 1 year ago

huh, I assumed there was some reason why a package-relative path was necessary...but you're right pathlib seems to work fine here. Not sure why that wasn't used from the beginning.

Rubo3 commented 1 year ago

Please tell me when you're ready to merge this PR. Thanks.

Rubo3 commented 1 year ago

Thank you!