diff --git a/CHANGES.rst b/CHANGES.rst index d6cda8bc..d4e66469 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,8 @@ +v4.6.3 +====== + +* Moved workaround for #327 to ``_compat`` module. + v4.6.2 ====== diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py index 1705129d..9f5bf347 100644 --- a/importlib_metadata/__init__.py +++ b/importlib_metadata/__init__.py @@ -7,7 +7,6 @@ import email import pathlib import operator -import platform import textwrap import warnings import functools @@ -21,6 +20,7 @@ NullFinder, PyPy_repr, install, + pypy_partial, ) from ._functools import method_cache from ._itertools import unique_everseen @@ -49,16 +49,6 @@ ] -def _pypy_partial(val): - """ - Adjust for variable stacklevel on partial under PyPy. - - Workaround for #327. - """ - is_pypy = platform.python_implementation() == 'PyPy' - return val + is_pypy - - class PackageNotFoundError(ModuleNotFoundError): """The package was not found.""" @@ -256,7 +246,7 @@ class DeprecatedList(list): warnings.warn, "EntryPoints list interface is deprecated. Cast to list if needed.", DeprecationWarning, - stacklevel=_pypy_partial(2), + stacklevel=pypy_partial(2), ) def __setitem__(self, *args, **kwargs): @@ -405,7 +395,7 @@ class Deprecated: warnings.warn, "SelectableGroups dict interface is deprecated. Use select.", DeprecationWarning, - stacklevel=_pypy_partial(2), + stacklevel=pypy_partial(2), ) def __getitem__(self, name): diff --git a/importlib_metadata/_compat.py b/importlib_metadata/_compat.py index 043ece02..1947d449 100644 --- a/importlib_metadata/_compat.py +++ b/importlib_metadata/_compat.py @@ -1,4 +1,5 @@ import sys +import platform __all__ = ['install', 'NullFinder', 'PyPy_repr', 'Protocol'] @@ -84,3 +85,13 @@ def make_param(name): if affected: # pragma: nocover __repr__ = __compat_repr__ del affected + + +def pypy_partial(val): + """ + Adjust for variable stacklevel on partial under PyPy. + + Workaround for #327. + """ + is_pypy = platform.python_implementation() == 'PyPy' + return val + is_pypy