Skip to content

Commit

Permalink
Update wrapper to rely on 'relative_to(walk_up=True)' on Python 3.12 …
Browse files Browse the repository at this point in the history
…and compatibility wrapper on Python 3.11 and earlier.
  • Loading branch information
jaraco committed Jun 23, 2024
1 parent 08d74cc commit 1584b96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import posixpath
import collections

from .compat.py38 import relative_fix
from .compat.py311 import relative_fix
from . import _adapters, _meta, _py39compat
from ._collections import FreezableDefaultDict, Pair
from ._compat import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

def wrap(path):
"""
Workaround for https://github.com/python/cpython/issues/67271 where ".."
isn't added by pathlib.Path.relative_to() when path is not
a subpath of root.
One example of such a package is dask-labextension, which uses
Workaround for https://github.com/python/cpython/issues/84538
to add backward compatibility for walk_up=True.
An example affected package is dask-labextension, which uses
jupyter-packaging to install JupyterLab javascript files outside
of site-packages.
"""
Expand All @@ -20,4 +19,4 @@ def relative_to(root, *, walk_up=False):
return types.SimpleNamespace(relative_to=relative_to)


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

0 comments on commit 1584b96

Please sign in to comment.