Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecations funcsigs #84

Merged
merged 3 commits into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/83.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove usage of python 3.3 and earlier ``funcsigs`` backport of ``inspect`..
23 changes: 7 additions & 16 deletions src/pip_shims/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import re
import sys
import types
from tempfile import TemporaryDirectory

from packaging import specifiers

Expand All @@ -23,13 +24,6 @@
suppress_setattr,
)

if sys.version_info[:2] < (3, 5):
from backports.tempfile import TemporaryDirectory
else:
from tempfile import TemporaryDirectory

from contextlib import ExitStack

if MYPY_RUNNING:
from optparse import Values
from typing import (
Expand Down Expand Up @@ -316,7 +310,7 @@ def get_tracker(tracker_creator=None, tracker_type="REQ"):
else:
req_tracker_args = []
_, required_args = get_method_args(tracker_creator.__init__) # type: ignore
with ExitStack() as ctx:
with contextlib.ExitStack() as ctx:
if root is None:
root = ctx.enter_context(TemporaryDirectory(prefix=prefix))
if root:
Expand Down Expand Up @@ -369,7 +363,7 @@ def wheel_cache(
raise TypeError("Format control or provider needed for wheel cache!")
if not format_control:
format_control = format_control_provider(None, None)
with ExitStack() as ctx:
with contextlib.ExitStack() as ctx:
ctx.enter_context(tempdir_manager_provider())
wheel_cache = wheel_cache_provider(cache_dir, format_control)
yield wheel_cache
Expand Down Expand Up @@ -573,7 +567,7 @@ def get_requirement_set(
)
if session is None and "session" in required_args:
session = get_session(install_cmd=install_command, options=options)
with ExitStack() as stack:
with contextlib.ExitStack() as stack:
if wheel_cache is None:
wheel_cache = stack.enter_context(wheel_cache_provider(cache_dir=cache_dir))
results["wheel_cache"] = wheel_cache
Expand Down Expand Up @@ -682,9 +676,6 @@ def get_package_finder(
if target_python and not received_python:
tags = target_python.get_tags()
version_impl = {t[0] for t in tags}
# impls = set([v[:2] for v in version_impl])
# impls.remove("py")
# impl = next(iter(impls), "py") if not target_python
versions = {v[2:] for v in version_impl}
build_kwargs.update(
{
Expand Down Expand Up @@ -978,7 +969,7 @@ def _ensure_wheel_cache(
if wheel_cache is not None:
yield wheel_cache
elif wheel_cache_provider is not None:
with ExitStack() as stack:
with contextlib.ExitStack() as stack:
cache_dir = getattr(options, "cache_dir", cache_dir)
format_control = getattr(
options,
Expand Down Expand Up @@ -1332,7 +1323,7 @@ def resolve( # noqa:C901
"cache_dir": cache_dir,
}
kwargs, options = populate_options(install_command, options, **kwarg_map)
with ExitStack() as ctx:
with contextlib.ExitStack() as ctx:
ctx.enter_context(tempdir_manager_provider())
kwargs = ctx.enter_context(
ensure_resolution_dirs(wheel_download_dir=wheel_download_dir, **kwargs)
Expand Down Expand Up @@ -1554,7 +1545,7 @@ def build_wheel( # noqa:C901
}
if not req and not reqset:
raise TypeError("Must provide either a requirement or requirement set to build")
with ExitStack() as ctx:
with contextlib.ExitStack() as ctx:
kwargs = kwarg_map.copy()
if wheel_cache is None and (reqset is not None or output_dir is None):
if install_command is None:
Expand Down
7 changes: 1 addition & 6 deletions src/pip_shims/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,9 @@ def get_allowed_args(fn_or_class):
default values.
:rtype: Tuple[List[str], Dict[str, Any]]
"""
try:
signature = inspect.signature(fn_or_class)
except AttributeError:
import funcsigs

signature = funcsigs.signature(fn_or_class)
args = []
kwargs = {}
signature = inspect.signature(fn_or_class)
for arg, param in signature.parameters.items():
if (
param.kind in (param.POSITIONAL_OR_KEYWORD, param.POSITIONAL_ONLY)
Expand Down