Skip to content

Commit

Permalink
Upgrade pydantic to 1.10.10 (#5769)
Browse files Browse the repository at this point in the history
  • Loading branch information
matteius authored Jul 1, 2023
1 parent ee20f40 commit 0bae654
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pipenv/vendor/pydantic/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2017, 2018, 2019, 2020, 2021 Samuel Colvin and other contributors
Copyright (c) 2017 to present Pydantic Services Inc. and individual contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 5 additions & 1 deletion pipenv/vendor/pydantic/env_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from .config import BaseConfig, Extra
from .fields import ModelField
from .main import BaseModel
from .types import JsonWrapper
from .typing import StrPath, display_as_type, get_origin, is_union
from .utils import deep_update, path_type, sequence_like
from .utils import deep_update, lenient_issubclass, path_type, sequence_like

env_file_sentinel = str(object())

Expand Down Expand Up @@ -231,6 +232,9 @@ def field_is_complex(self, field: ModelField) -> Tuple[bool, bool]:
"""
Find out if a field is complex, and if so whether JSON errors should be ignored
"""
if lenient_issubclass(field.annotation, JsonWrapper):
return False, False

if field.is_complex():
allow_parse_failure = False
elif is_union(get_origin(field.type_)) and field.sub_fields and any(f.is_complex() for f in field.sub_fields):
Expand Down
14 changes: 12 additions & 2 deletions pipenv/vendor/pydantic/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Any,
ClassVar,
Dict,
ForwardRef,
Generic,
Iterator,
List,
Expand All @@ -19,7 +20,7 @@
)
from weakref import WeakKeyDictionary, WeakValueDictionary

from pipenv.patched.pip._vendor.typing_extensions import Annotated
from pipenv.patched.pip._vendor.typing_extensions import Annotated, Literal as ExtLiteral

from .class_validators import gather_all_validators
from .fields import DeferredType
Expand All @@ -30,6 +31,8 @@

if sys.version_info >= (3, 10):
from typing import _UnionGenericAlias
if sys.version_info >= (3, 8):
from typing import Literal

GenericModelT = TypeVar('GenericModelT', bound='GenericModel')
TypeVarType = Any # since mypy doesn't allow the use of TypeVar as a type
Expand Down Expand Up @@ -267,6 +270,8 @@ def replace_types(type_: Any, type_map: Mapping[Any, Any]) -> Any:
annotated_type, *annotations = type_args
return Annotated[replace_types(annotated_type, type_map), tuple(annotations)]

if (origin_type is ExtLiteral) or (sys.version_info >= (3, 8) and origin_type is Literal):
return type_map.get(type_, type_)
# Having type args is a good indicator that this is a typing module
# class instantiation or a generic alias of some sort.
if type_args:
Expand Down Expand Up @@ -317,7 +322,12 @@ def replace_types(type_: Any, type_map: Mapping[Any, Any]) -> Any:

# If all else fails, we try to resolve the type directly and otherwise just
# return the input with no modifications.
return type_map.get(type_, type_)
new_type = type_map.get(type_, type_)
# Convert string to ForwardRef
if isinstance(new_type, str):
return ForwardRef(new_type)
else:
return new_type


def check_parameters_count(cls: Type[GenericModel], parameters: Tuple[Any, ...]) -> None:
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/pydantic/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def make_literal_validator(type_: Any) -> Callable[[Any], Any]:
def literal_validator(v: Any) -> Any:
try:
return allowed_choices[v]
except KeyError:
except (KeyError, TypeError):
raise errors.WrongConstantError(given=v, permitted=permitted_choices)

return literal_validator
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.9'
VERSION = '1.10.10'

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 @@ -8,7 +8,7 @@ pexpect==4.8.0
pipdeptree==2.8.0
plette==0.4.4
ptyprocess==0.7.0
pydantic==1.10.9
pydantic==1.10.10
python-dotenv==1.0.0
pythonfinder==2.0.4
requirementslib==3.0.0
Expand Down

0 comments on commit 0bae654

Please sign in to comment.