Skip to content

Commit

Permalink
Upgrade pydantic to v1.10.9 (#5729)
Browse files Browse the repository at this point in the history
  • Loading branch information
matteius authored Jun 11, 2023
1 parent 2d52034 commit bc277a1
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 22 deletions.
7 changes: 6 additions & 1 deletion pipenv/vendor/pydantic/_hypothesis_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#
# conlist() and conset() are unsupported for now, because the workarounds for
# Cython and Hypothesis to handle parametrized generic types are incompatible.
# Once Cython can support 'normal' generics we'll revisit this.
# We are rethinking Hypothesis compatibility in Pydantic v2.

# Emails
try:
Expand Down Expand Up @@ -168,6 +168,11 @@ def add_luhn_digit(card_number: str) -> str:
st.register_type_strategy(pydantic.StrictStr, st.text())


# FutureDate, PastDate
st.register_type_strategy(pydantic.FutureDate, st.dates(min_value=datetime.date.today() + datetime.timedelta(days=1)))
st.register_type_strategy(pydantic.PastDate, st.dates(max_value=datetime.date.today() - datetime.timedelta(days=1)))


# Constrained-type resolver functions
#
# For these ones, we actually want to inspect the type in order to work out a
Expand Down
3 changes: 2 additions & 1 deletion pipenv/vendor/pydantic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class Extra(str, Enum):


# https://github.com/cython/cython/issues/4003
# Will be fixed with Cython 3 but still in alpha right now
# Fixed in Cython 3 and Pydantic v1 won't support Cython 3.
# Pydantic v2 doesn't depend on Cython at all.
if not compiled:
from pipenv.patched.pip._vendor.typing_extensions import TypedDict

Expand Down
23 changes: 20 additions & 3 deletions pipenv/vendor/pydantic/mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,32 @@ def add_construct_method(self, fields: List['PydanticModelField']) -> None:
obj_type = ctx.api.named_type(f'{BUILTINS_NAME}.object')
self_tvar_name = '_PydanticBaseModel' # Make sure it does not conflict with other names in the class
tvar_fullname = ctx.cls.fullname + '.' + self_tvar_name
tvd = TypeVarDef(self_tvar_name, tvar_fullname, -1, [], obj_type)
self_tvar_expr = TypeVarExpr(self_tvar_name, tvar_fullname, [], obj_type)
if MYPY_VERSION_TUPLE >= (1, 4):
tvd = TypeVarType(
self_tvar_name,
tvar_fullname,
-1,
[],
obj_type,
AnyType(TypeOfAny.from_omitted_generics), # type: ignore[arg-type]
)
self_tvar_expr = TypeVarExpr(
self_tvar_name,
tvar_fullname,
[],
obj_type,
AnyType(TypeOfAny.from_omitted_generics), # type: ignore[arg-type]
)
else:
tvd = TypeVarDef(self_tvar_name, tvar_fullname, -1, [], obj_type)
self_tvar_expr = TypeVarExpr(self_tvar_name, tvar_fullname, [], obj_type)
ctx.cls.info.names[self_tvar_name] = SymbolTableNode(MDEF, self_tvar_expr)

# Backward-compatible with TypeVarDef from Mypy 0.910.
if isinstance(tvd, TypeVarType):
self_type = tvd
else:
self_type = TypeVarType(tvd) # type: ignore[call-arg]
self_type = TypeVarType(tvd)

add_method(
ctx,
Expand Down
8 changes: 6 additions & 2 deletions pipenv/vendor/pydantic/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
import warnings
from datetime import date
from decimal import Decimal
from decimal import Decimal, InvalidOperation
from enum import Enum
from pathlib import Path
from types import new_class
Expand Down Expand Up @@ -691,7 +691,11 @@ def __get_validators__(cls) -> 'CallableGenerator':

@classmethod
def validate(cls, value: Decimal) -> Decimal:
digit_tuple, exponent = value.as_tuple()[1:]
try:
normalized_value = value.normalize()
except InvalidOperation:
normalized_value = value
digit_tuple, exponent = normalized_value.as_tuple()[1:]
if exponent in {'F', 'n', 'N'}:
raise errors.DecimalIsNotFiniteError()

Expand Down
10 changes: 1 addition & 9 deletions pipenv/vendor/pydantic/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,7 @@ def is_union(tp: Optional[Type[Any]]) -> bool:
WithArgsTypes = (typing._GenericAlias, types.GenericAlias, types.UnionType)


if sys.version_info < (3, 9):
StrPath = Union[str, PathLike]
else:
StrPath = Union[str, PathLike]
# TODO: Once we switch to Cython 3 to handle generics properly
# (https://github.com/cython/cython/issues/2753), use following lines instead
# of the one above
# # os.PathLike only becomes subscriptable from Python 3.9 onwards
# StrPath = Union[str, PathLike[str]]
StrPath = Union[str, PathLike]


if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/pydantic/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__all__ = 'compiled', 'VERSION', 'version_info'

VERSION = '1.10.8'
VERSION = '1.10.9'

try:
import cython # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pexpect==4.8.0
pipdeptree==2.8.0
plette==0.4.4
ptyprocess==0.7.0
pydantic==1.10.8
pydantic==1.10.9
python-dotenv==1.0.0
pythonfinder==2.0.4
requirementslib==2.3.0
Expand Down
4 changes: 0 additions & 4 deletions tests/integration/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
"""Tests to ensure `pipenv --option` works.
"""

import os
import re
from pathlib import Path
import pytest

from flaky import flaky

from pipenv.utils.processes import subprocess_run
from pipenv.utils.shell import normalize_drive
Expand Down

0 comments on commit bc277a1

Please sign in to comment.