Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/importlib_metadata/compat/py311.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

5 statements  

1import os 

2import pathlib 

3import sys 

4import types 

5 

6 

7def wrap(path): # pragma: no cover 

8 """ 

9 Workaround for https://github.com/python/cpython/issues/84538 

10 to add backward compatibility for walk_up=True. 

11 An example affected package is dask-labextension, which uses 

12 jupyter-packaging to install JupyterLab javascript files outside 

13 of site-packages. 

14 """ 

15 

16 def relative_to(root, *, walk_up=False): 

17 return pathlib.Path(os.path.relpath(path, root)) 

18 

19 return types.SimpleNamespace(relative_to=relative_to) 

20 

21 

22relative_fix = wrap if sys.version_info < (3, 12) else lambda x: x