Skip to content

Commit 18ce6aa

Browse files
Merge pull request #55 from josh-ashkinaze/dev/pkg_resources_change
(docs) re-format get_resource_path docs for sphinx rst
2 parents 2c0255e + 2861317 commit 18ce6aa

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

plurals/helpers.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -220,26 +220,19 @@ def format(self, avoid_double_period=True, **kwargs):
220220

221221

222222
def get_resource_path(package: str, resource: str) -> str:
223-
"""
224-
Get the path to a resource file, supporting both pkg_resources and importlib.resources.
223+
"""Get the path to a resource file, supporting both pkg_resources and importlib.resources.
225224
Falls back to importlib.resources if pkg_resources is not available.
226225
227226
Problem this solves:
228-
- In python 3.12, pkg_resources is being deprecated in favor of importlib.resources, and
229-
it no longer comes with pkg_resources. This creates an import error unless user does `pip install setuptools` but it is
230-
bad practice to add setuptools as a runtime dependency.
231-
232-
- If I just switch to importlib, this is limiting since importlib is only for 3.9+.
233-
234-
- So the solution is to use pkg_resources if available, and if not, use importlib.resources.
235-
227+
- In python 3.12, pkg_resources is being deprecated in favor of importlib.resources, and
228+
it no longer comes with pkg_resources. This creates an import error unless user does
229+
`pip install setuptools` but it is bad practice to add setuptools as a runtime dependency.
230+
- If I just switch to importlib, this is limiting since importlib is only for 3.9+.
231+
- So the solution is to use pkg_resources if available, and if not, use importlib.resources.
236232
237233
Args:
238-
package: The package name (just __name__ usually)
239-
resource: The resource path relative to the package
240-
241-
Returns:
242-
str: The full path to the resource
234+
package (str): The package name (just __name__ usually)
235+
resource (str): The resource path relative to the package
243236
"""
244237
try:
245238
import pkg_resources
@@ -248,4 +241,4 @@ def get_resource_path(package: str, resource: str) -> str:
248241
from importlib import resources
249242
root_package = package.split('.')[0]
250243
with resources.path(root_package, resource) as path:
251-
return str(path)
244+
return str(path)

0 commit comments

Comments
 (0)