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

More vendor clean up #5450

Merged
merged 17 commits into from
Nov 4, 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: 0 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:

python-version: "3.10"
- name: Collect Workflow Telemetry
uses: runforesight/foresight-workflow-kit-action@v1
Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SHELL := bash
get_venv_dir:=$(shell mktemp -d 2>/dev/null || mktemp -d -t 'tmpvenv')
venv_dir := $(get_venv_dir)/pipenv_venv
venv_file := $(CURDIR)/.test_venv
Expand All @@ -18,6 +19,7 @@ write_git_tmpdir = $(file > $(GITDIR_STAMPFILE),$(create_git_tmpdir))
get_checkout_dir = $(file < $(GITDIR_STAMPFILE))
get_checkout_subdir = $(addprefix $(get_checkout_dir), $(1))
pip-checkout-dir = $(get_checkout_dir)/patch-pip
PY ?= python

format:
black pipenv/*.py
Expand Down Expand Up @@ -47,7 +49,7 @@ ramdisk:
.PHONY: ramdisk-virtualenv
ramdisk-virtualenv: ramdisk
[ ! -e "/mnt/ramdisk/.venv/bin/activate" ] && \
python -m venv /mnt/ramdisk/.venv
$(PY) -m venv /mnt/ramdisk/.venv
echo "/mnt/ramdisk/.venv" > $(venv_file)

.PHONY: virtualenv
Expand Down Expand Up @@ -172,3 +174,9 @@ reimport-pip-patch:
@sed -i -r 's:([a-b]\/)src/:\1pipenv/patched/:g' $(pip-checkout-dir)/pip*.patch
@find $(pip-checkout-dir) -maxdepth 1 -regex ".*/pip[0-9]+.patch" -exec cp {} $(CURDIR)/tasks/vendoring/patches/patched/ \;
@find $(pip-checkout-dir) -maxdepth 1 -regex ".*/_post-pip-[^/\.]*.patch" -exec cp {} $(CURDIR)/tasks/vendoring/patches/patched/ \;


.PHONY: pypi-server
pypi-server: SERVER ?= gunicorn
pypi-server:
pipenv run pypi-server run --server $(SERVER) -v --host=0.0.0.0 --port=8080 --hash-algo=sha256 --disable-fallback ./tests/pypi/ ./tests/fixtures
3 changes: 3 additions & 0 deletions news/5450.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Drop tomli, which is not used anymore.
Bump attrs version see #5449.
Drop distlib, colorama and platformdirs - use the ones from pip._vendor.
2 changes: 1 addition & 1 deletion pipenv/patched/pip/_vendor/pep517/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
try:
from zipfile import Path
except ImportError:
from pipenv.vendor.zipp import Path
from zipp import Path

from .build import compat_system, load_system, validate_system
from .dirtools import dir_to_zipfile
Expand Down
9 changes: 5 additions & 4 deletions pipenv/vendor/attr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import absolute_import, division, print_function
# SPDX-License-Identifier: MIT


import sys

Expand All @@ -22,7 +23,7 @@
from ._version_info import VersionInfo


__version__ = "21.2.0"
__version__ = "22.1.0"
__version_info__ = VersionInfo._from_version_string(__version__)

__title__ = "attrs"
Expand Down Expand Up @@ -73,6 +74,6 @@
]

if sys.version_info[:2] >= (3, 6):
from ._next_gen import define, field, frozen, mutable
from ._next_gen import define, field, frozen, mutable # noqa: F401

__all__.extend((define, field, frozen, mutable))
__all__.extend(("define", "field", "frozen", "mutable"))
39 changes: 25 additions & 14 deletions pipenv/vendor/attr/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import sys
from typing import (
Any,
Callable,
ClassVar,
Dict,
Generic,
List,
Mapping,
Optional,
Protocol,
Sequence,
Tuple,
Type,
Expand All @@ -22,9 +24,9 @@ from . import exceptions as exceptions
from . import filters as filters
from . import setters as setters
from . import validators as validators
from ._cmp import cmp_using as cmp_using
from ._version_info import VersionInfo


__version__: str
__version_info__: VersionInfo
__title__: str
Expand All @@ -49,12 +51,18 @@ _OnSetAttrType = Callable[[Any, Attribute[Any], Any], Any]
_OnSetAttrArgType = Union[
_OnSetAttrType, List[_OnSetAttrType], setters._NoOpType
]
_FieldTransformer = Callable[[type, List[Attribute[Any]]], List[Attribute[Any]]]
_FieldTransformer = Callable[
[type, List[Attribute[Any]]], List[Attribute[Any]]
]
# FIXME: in reality, if multiple validators are passed they must be in a list
# or tuple, but those are invariant and so would prevent subtypes of
# _ValidatorType from working when passed in a list or tuple.
_ValidatorArgType = Union[_ValidatorType[_T], Sequence[_ValidatorType[_T]]]

# A protocol to be able to statically accept an attrs class.
class AttrsInstance(Protocol):
__attrs_attrs__: ClassVar[Any]

# _make --

NOTHING: object
Expand All @@ -64,7 +72,6 @@ NOTHING: object
# Work around mypy issue #4554 in the common case by using an overload.
if sys.version_info >= (3, 8):
from typing import Literal

@overload
def Factory(factory: Callable[[], _T]) -> _T: ...
@overload
Expand All @@ -77,6 +84,7 @@ if sys.version_info >= (3, 8):
factory: Callable[[], _T],
takes_self: Literal[False],
) -> _T: ...

else:
@overload
def Factory(factory: Callable[[], _T]) -> _T: ...
Expand Down Expand Up @@ -117,7 +125,6 @@ class Attribute(Generic[_T]):
type: Optional[Type[_T]]
kw_only: bool
on_setattr: _OnSetAttrType

def evolve(self, **changes: Any) -> "Attribute[Any]": ...

# NOTE: We had several choices for the annotation to use for type arg:
Expand Down Expand Up @@ -315,6 +322,7 @@ def attrs(
getstate_setstate: Optional[bool] = ...,
on_setattr: Optional[_OnSetAttrArgType] = ...,
field_transformer: Optional[_FieldTransformer] = ...,
match_args: bool = ...,
) -> _C: ...
@overload
@__dataclass_transform__(order_default=True, field_descriptors=(attrib, field))
Expand All @@ -341,6 +349,7 @@ def attrs(
getstate_setstate: Optional[bool] = ...,
on_setattr: Optional[_OnSetAttrArgType] = ...,
field_transformer: Optional[_FieldTransformer] = ...,
match_args: bool = ...,
) -> Callable[[_C], _C]: ...
@overload
@__dataclass_transform__(field_descriptors=(attrib, field))
Expand All @@ -365,6 +374,7 @@ def define(
getstate_setstate: Optional[bool] = ...,
on_setattr: Optional[_OnSetAttrArgType] = ...,
field_transformer: Optional[_FieldTransformer] = ...,
match_args: bool = ...,
) -> _C: ...
@overload
@__dataclass_transform__(field_descriptors=(attrib, field))
Expand All @@ -389,18 +399,15 @@ def define(
getstate_setstate: Optional[bool] = ...,
on_setattr: Optional[_OnSetAttrArgType] = ...,
field_transformer: Optional[_FieldTransformer] = ...,
match_args: bool = ...,
) -> Callable[[_C], _C]: ...

mutable = define
frozen = define # they differ only in their defaults

# TODO: add support for returning NamedTuple from the mypy plugin
class _Fields(Tuple[Attribute[Any], ...]):
def __getattr__(self, name: str) -> Attribute[Any]: ...

def fields(cls: type) -> _Fields: ...
def fields_dict(cls: type) -> Dict[str, Attribute[Any]]: ...
def validate(inst: Any) -> None: ...
def fields(cls: Type[AttrsInstance]) -> Any: ...
def fields_dict(cls: Type[AttrsInstance]) -> Dict[str, Attribute[Any]]: ...
def validate(inst: AttrsInstance) -> None: ...
def resolve_types(
cls: _C,
globalns: Optional[Dict[str, Any]] = ...,
Expand Down Expand Up @@ -442,18 +449,22 @@ def make_class(
# these:
# https://github.com/python/mypy/issues/4236
# https://github.com/python/typing/issues/253
# XXX: remember to fix attrs.asdict/astuple too!
def asdict(
inst: Any,
inst: AttrsInstance,
recurse: bool = ...,
filter: Optional[_FilterType[Any]] = ...,
dict_factory: Type[Mapping[Any, Any]] = ...,
retain_collection_types: bool = ...,
value_serializer: Optional[Callable[[type, Attribute[Any], Any], Any]] = ...,
value_serializer: Optional[
Callable[[type, Attribute[Any], Any], Any]
] = ...,
tuple_keys: Optional[bool] = ...,
) -> Dict[str, Any]: ...

# TODO: add support for returning NamedTuple from the mypy plugin
def astuple(
inst: Any,
inst: AttrsInstance,
recurse: bool = ...,
filter: Optional[_FilterType[Any]] = ...,
tuple_factory: Type[Sequence[Any]] = ...,
Expand Down
9 changes: 6 additions & 3 deletions pipenv/vendor/attr/_cmp.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import absolute_import, division, print_function
# SPDX-License-Identifier: MIT


import functools
import types

from ._compat import new_class
from ._make import _make_ne


Expand Down Expand Up @@ -78,7 +79,9 @@ def cmp_using(
num_order_functions += 1
body["__ge__"] = _make_operator("ge", ge)

type_ = new_class(class_name, (object,), {}, lambda ns: ns.update(body))
type_ = types.new_class(
class_name, (object,), {}, lambda ns: ns.update(body)
)

# Add same type requirement.
if require_same_type:
Expand Down
5 changes: 2 additions & 3 deletions pipenv/vendor/attr/_cmp.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Type

from . import _CompareWithType
from typing import Any, Callable, Optional, Type

_CompareWithType = Callable[[Any, Any], bool]

def cmp_using(
eq: Optional[_CompareWithType],
Expand Down
Loading