1
0
mirror of synced 2024-12-22 12:50:33 +01:00

dev-python/pydantic: present in ::gentoo

This commit is contained in:
Horea Christian 2022-03-26 22:10:23 -04:00
parent f0f57a263d
commit 7356eb75a2
5 changed files with 0 additions and 275 deletions

View File

@ -1,2 +0,0 @@
DIST pydantic-1.8.2_p20210719.tar.gz 310729 SHA256 a1cf7ecedac6b78632c0ac630f053866c9205cbf0163118ff6b9ee850a0d478c SHA512 c9d91788b3143b211755806e533ae0ccafa2ab101159f98eeba921ec9370956e8f8b0f210e6ddddcef2345ea391d2e1011ea5498d2f7985bd711f48d025e30d5 WHIRLPOOL 643a18942d6bc0961acd7a0a9c706bd2cf430914347e46e36222dcedfa5fa0c7ee6e0237453a5ebf2c323da3c58f149ccc05cbfa5c3bfb1a08c2d44231b70af9
DIST pydantic-1.9.0.tar.gz 299758 SHA256 742645059757a56ecd886faf4ed2441b9c0cd406079c2b4bee51bcc3fbcd510a SHA512 ace542ff12698d568f2bea6121afc889c51892042b1a1b98464a6da6f71e50ecd8aafff7abd7ffd16983769844f7c970099d1fee7aa788f2e78172c0d5c4f472 WHIRLPOOL 4366d1ab7969a60467fa051025cd1f2557345a4340126808c1e0a59964d6e39675f6444468b1b04b6802bb17d48d2f3624b07fbea22486497d8e5e5f3921dc9f

View File

@ -1,174 +0,0 @@
From: PrettyWood <em.jolibois@gmail.com>
Date: Tue, 10 Aug 2021 18:00:16 +0200
Subject: [PATCH 1/2] refactor: rename `is_union` into `is_union_origin`
https://github.com/samuelcolvin/pydantic/pull/3085
--- a/pydantic/fields.py
+++ b/pydantic/fields.py
@@ -41,7 +41,7 @@
is_literal_type,
is_new_type,
is_typeddict,
- is_union,
+ is_union_origin,
new_type_supertype,
)
from .utils import PyObjectStr, Representation, ValueItems, lenient_issubclass, sequence_like, smart_deepcopy
@@ -557,7 +557,7 @@ def _type_analysis(self) -> None: # noqa: C901 (ignore complexity)
return
if origin is Callable:
return
- if is_union(origin):
+ if is_union_origin(origin):
types_ = []
for type_ in get_args(self.type_):
if type_ is NoneType:
--- a/pydantic/main.py
+++ b/pydantic/main.py
@@ -38,7 +38,7 @@
get_origin,
is_classvar,
is_namedtuple,
- is_union,
+ is_union_origin,
resolve_annotations,
update_field_forward_refs,
)
@@ -176,7 +176,7 @@ def is_untouched(v: Any) -> bool:
elif is_valid_field(ann_name):
validate_field_name(bases, ann_name)
value = namespace.get(ann_name, Undefined)
- allowed_types = get_args(ann_type) if is_union(get_origin(ann_type)) else (ann_type,)
+ allowed_types = get_args(ann_type) if is_union_origin(get_origin(ann_type)) else (ann_type,)
if (
is_untouched(value)
and ann_type != PyObject
--- a/pydantic/schema.py
+++ b/pydantic/schema.py
@@ -71,7 +71,7 @@
is_callable_type,
is_literal_type,
is_namedtuple,
- is_union,
+ is_union_origin,
)
from .utils import ROOT_KEY, get_model, lenient_issubclass, sequence_like
@@ -966,7 +966,7 @@ def go(type_: Any) -> Type[Any]:
if origin is Annotated:
return go(args[0])
- if is_union(origin):
+ if is_union_origin(origin):
return Union[tuple(go(a) for a in args)] # type: ignore
if issubclass(origin, List) and (field_info.min_items is not None or field_info.max_items is not None):
--- a/pydantic/typing.py
+++ b/pydantic/typing.py
@@ -191,14 +191,14 @@ def get_args(tp: Type[Any]) -> Tuple[Any, ...]:
if sys.version_info < (3, 10):
- def is_union(tp: Type[Any]) -> bool:
+ def is_union_origin(tp: Type[Any]) -> bool:
return tp is Union
else:
import types
- def is_union(tp: Type[Any]) -> bool:
+ def is_union_origin(tp: Type[Any]) -> bool:
return tp is Union or tp is types.Union
@@ -251,7 +251,7 @@ def is_union(tp: Type[Any]) -> bool:
'get_origin',
'typing_base',
'get_all_type_hints',
- 'is_union',
+ 'is_union_origin',
)
From: PrettyWood <em.jolibois@gmail.com>
Date: Tue, 10 Aug 2021 18:02:57 +0200
Subject: [PATCH 2/2] fix: "new" union and generic types are not the same as
`typing.GenericAlias`
--- a/pydantic/typing.py
+++ b/pydantic/typing.py
@@ -28,10 +28,10 @@
from typing import _Final as typing_base # type: ignore
try:
- from typing import GenericAlias # type: ignore
+ from typing import GenericAlias as TypingGenericAlias # type: ignore
except ImportError:
# python < 3.9 does not have GenericAlias (list[int], tuple[str, ...] and so on)
- GenericAlias = ()
+ TypingGenericAlias = ()
if sys.version_info < (3, 7):
@@ -194,12 +194,16 @@ def get_args(tp: Type[Any]) -> Tuple[Any, ...]:
def is_union_origin(tp: Type[Any]) -> bool:
return tp is Union
+ WithArgsTypes = (TypingGenericAlias,)
else:
import types
+ import typing
def is_union_origin(tp: Type[Any]) -> bool:
- return tp is Union or tp is types.Union
+ return tp is Union or tp is types.UnionType # type: ignore # noqa: E721
+
+ WithArgsTypes = (typing._GenericAlias, types.GenericAlias, types.UnionType) # type: ignore
if TYPE_CHECKING:
@@ -246,7 +250,7 @@ def is_union_origin(tp: Type[Any]) -> bool:
'CallableGenerator',
'ReprArgs',
'CallableGenerator',
- 'GenericAlias',
+ 'WithArgsTypes',
'get_args',
'get_origin',
'typing_base',
@@ -260,10 +264,10 @@ def is_union_origin(tp: Type[Any]) -> bool:
def display_as_type(v: Type[Any]) -> str:
- if not isinstance(v, typing_base) and not isinstance(v, GenericAlias) and not isinstance(v, type):
+ if not isinstance(v, typing_base) and not isinstance(v, WithArgsTypes) and not isinstance(v, type):
v = v.__class__
- if isinstance(v, GenericAlias):
+ if isinstance(v, WithArgsTypes):
# Generic alias are constructs like `list[int]`
return str(v).replace('typing.', '')
--- a/pydantic/utils.py
+++ b/pydantic/utils.py
@@ -23,7 +23,7 @@
Union,
)
-from .typing import GenericAlias, NoneType, display_as_type
+from .typing import NoneType, WithArgsTypes, display_as_type
from .version import version_info
if TYPE_CHECKING:
@@ -152,7 +152,7 @@ def lenient_issubclass(cls: Any, class_or_tuple: Union[Type[Any], Tuple[Type[Any
try:
return isinstance(cls, type) and issubclass(cls, class_or_tuple)
except TypeError:
- if isinstance(cls, GenericAlias):
+ if isinstance(cls, WithArgsTypes):
return False
raise # pragma: no cover

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>gentoo@chymera.eu</email>
<name>Horea Christian</name>
</maintainer>
<maintainer type="project">
<email>sci@gentoo.org</email>
<name>Gentoo Science Project</name>
</maintainer>
<upstream>
<remote-id type="pypi">pydantic</remote-id>
<remote-id type="github">samuelcolvin/pydantic</remote-id>
<bugs-to>https://github.com/samuelcolvin/pydantic/issues</bugs-to>
<doc>https://pydantic-docs.helpmanual.io/</doc>
</upstream>
</pkgmetadata>

View File

@ -1,45 +0,0 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{8..10} )
inherit distutils-r1
COMMIT=0c26c1c4e288e0d41d2c3890d5b3befa7579455c
DESCRIPTION="Data parsing and validation using Python type hints"
HOMEPAGE="https://github.com/samuelcolvin/pydantic"
SRC_URI="
https://github.com/samuelcolvin/pydantic/archive/${COMMIT}.tar.gz
-> ${P}.tar.gz"
S="${WORKDIR}/${PN}-${COMMIT}"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
RDEPEND="
dev-python/typing-extensions[${PYTHON_USEDEP}]
"
BDEPEND="
dev-python/cython[${PYTHON_USEDEP}]
test? (
dev-python/hypothesis[${PYTHON_USEDEP}]
dev-python/pytest-mock[${PYTHON_USEDEP}]
dev-python/python-email-validator[${PYTHON_USEDEP}]
)
"
PATCHES=(
"${FILESDIR}/${P}-update-py3.10rc1.patch"
)
distutils_enable_tests pytest
src_prepare() {
# they hard-code `-O3`
# https://github.com/samuelcolvin/pydantic/issues/3942
sed -i -e '/CFLAGS/d' setup.py || die
distutils-r1_src_prepare
}

View File

@ -1,36 +0,0 @@
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{8..10} )
inherit distutils-r1
DESCRIPTION="Data parsing and validation using Python type hints"
HOMEPAGE="https://github.com/samuelcolvin/pydantic"
SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
RDEPEND="
dev-python/python-dotenv[${PYTHON_USEDEP}]
dev-python/python-email-validator[${PYTHON_USEDEP}]
dev-python/typing-extensions[${PYTHON_USEDEP}]
"
BDEPEND="
dev-python/cython[${PYTHON_USEDEP}]
test? (
dev-python/pytest-mock[${PYTHON_USEDEP}]
)
"
distutils_enable_tests pytest
src_prepare() {
# they hard-code `-O3`
# https://github.com/samuelcolvin/pydantic/issues/3942
sed -i -e '/CFLAGS/d' setup.py || die
distutils-r1_src_prepare
}