Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/pydantic/files/, dev-python/pydantic/
Date: Tue, 04 May 2021 22:18:02
Message-Id: 1620166624.f374396f4266cf1b23ff6deb5faec6852c283a6c.sam@gentoo
1 commit: f374396f4266cf1b23ff6deb5faec6852c283a6c
2 Author: Jakov Smolic <jakov.smolic <AT> sartura <DOT> hr>
3 AuthorDate: Thu Apr 29 18:28:07 2021 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Tue May 4 22:17:04 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f374396f
7
8 dev-python/pydantic: Remove old 1.6.1
9
10 Closes: https://bugs.gentoo.org/764815
11 Signed-off-by: Jakov Smolic <jakov.smolic <AT> sartura.hr>
12 Signed-off-by: Sam James <sam <AT> gentoo.org>
13
14 dev-python/pydantic/Manifest | 1 -
15 .../pydantic/files/pydantic-1.6.1-fix-tests.patch | 45 ---
16 .../pydantic/files/pydantic-1.6.1-py39.patch | 316 ---------------------
17 dev-python/pydantic/pydantic-1.6.1.ebuild | 38 ---
18 4 files changed, 400 deletions(-)
19
20 diff --git a/dev-python/pydantic/Manifest b/dev-python/pydantic/Manifest
21 index b460cb616af..20bf88990f2 100644
22 --- a/dev-python/pydantic/Manifest
23 +++ b/dev-python/pydantic/Manifest
24 @@ -1,2 +1 @@
25 -DIST pydantic-1.6.1.tar.gz 244677 BLAKE2B 0a1d6986858ab753cbc4dd262bd268b2a365c241a7de106a7bf21714c6c499c7dbacaea095789d3503507965ca50106da32545be670ed0261827f1fe0316ff67 SHA512 b0442f78a661f56d29697da7e27393261420bdb0f08473d2f7872145a49a18de8c17c903d0899a44263bcd8229e8790161da032dd5a3d5f2dae347c66bd6a567
26 DIST pydantic-1.8.1.tar.gz 300512 BLAKE2B a7840bd895c73c3049184fc2c4a165783fd68a82290c3826be53667e7b7919580493aff9f2aaa25274b0251da14218dd6f7a41c1cb3cb55f0fbb0c90f79b7833 SHA512 dc58ab2e411744e63408c952c92c589acf037e809c60b85e02f277af2c6342c99c4fbfa7a585f14e57256912c0e6471821973bd2f755aac3822eb3a7883fd407
27
28 diff --git a/dev-python/pydantic/files/pydantic-1.6.1-fix-tests.patch b/dev-python/pydantic/files/pydantic-1.6.1-fix-tests.patch
29 deleted file mode 100644
30 index 1d6dc5d311a..00000000000
31 --- a/dev-python/pydantic/files/pydantic-1.6.1-fix-tests.patch
32 +++ /dev/null
33 @@ -1,45 +0,0 @@
34 -commit 44eac223df11a1b711ffe0d7946019a173c2a88e
35 -Author: Louis Sautier <sautier.louis@×××××.com>
36 -Date: Thu Oct 8 14:19:58 2020 +0200
37 -
38 - test_config_file_settings_nornir: use less common env. var names
39 -
40 - Gentoo's Portage sets A during the test phase, switching to less common
41 - environment variable names reduces the likelihood of something similar
42 - happening.
43 -
44 -diff --git a/tests/test_settings.py b/tests/test_settings.py
45 -index d24aae3..1f4d678 100644
46 ---- a/tests/test_settings.py
47 -+++ b/tests/test_settings.py
48 -@@ -437,21 +437,21 @@ def test_config_file_settings_nornir(env):
49 - """
50 -
51 - class Settings(BaseSettings):
52 -- a: str
53 -- b: str
54 -- c: str
55 -+ param_a: str
56 -+ param_b: str
57 -+ param_c: str
58 -
59 - def _build_values(self, init_kwargs, _env_file, _env_file_encoding):
60 - config_settings = init_kwargs.pop('__config_settings__')
61 - return {**config_settings, **init_kwargs, **self._build_environ()}
62 -
63 -- env.set('C', 'env setting c')
64 -+ env.set('PARAM_C', 'env setting c')
65 -
66 -- config = {'a': 'config a', 'b': 'config b', 'c': 'config c'}
67 -- s = Settings(__config_settings__=config, b='argument b', c='argument c')
68 -- assert s.a == 'config a'
69 -- assert s.b == 'argument b'
70 -- assert s.c == 'env setting c'
71 -+ config = {'param_a': 'config a', 'param_b': 'config b', 'param_c': 'config c'}
72 -+ s = Settings(__config_settings__=config, param_b='argument b', param_c='argument c')
73 -+ assert s.param_a == 'config a'
74 -+ assert s.param_b == 'argument b'
75 -+ assert s.param_c == 'env setting c'
76 -
77 -
78 - test_env_file = """\
79
80 diff --git a/dev-python/pydantic/files/pydantic-1.6.1-py39.patch b/dev-python/pydantic/files/pydantic-1.6.1-py39.patch
81 deleted file mode 100644
82 index 7cd5290cd59..00000000000
83 --- a/dev-python/pydantic/files/pydantic-1.6.1-py39.patch
84 +++ /dev/null
85 @@ -1,316 +0,0 @@
86 -diff --git a/changes/1832-PrettyWood.md b/changes/1832-PrettyWood.md
87 -new file mode 100644
88 -index 000000000..5038a0da0
89 ---- /dev/null
90 -+++ b/changes/1832-PrettyWood.md
91 -@@ -0,0 +1 @@
92 -+add basic support of python 3.9
93 -diff --git a/pydantic/fields.py b/pydantic/fields.py
94 -index 01792b628..c52b34ea4 100644
95 ---- a/pydantic/fields.py
96 -+++ b/pydantic/fields.py
97 -@@ -32,6 +32,8 @@
98 - NoArgAnyCallable,
99 - NoneType,
100 - display_as_type,
101 -+ get_args,
102 -+ get_origin,
103 - is_literal_type,
104 - is_new_type,
105 - new_type_supertype,
106 -@@ -411,7 +413,7 @@ def _type_analysis(self) -> None: # noqa: C901 (ignore complexity)
107 - elif is_literal_type(self.type_):
108 - return
109 -
110 -- origin = getattr(self.type_, '__origin__', None)
111 -+ origin = get_origin(self.type_)
112 - if origin is None:
113 - # field is not "typing" object eg. Union, Dict, List etc.
114 - # allow None for virtual superclasses of NoneType, e.g. Hashable
115 -@@ -422,7 +424,7 @@ def _type_analysis(self) -> None: # noqa: C901 (ignore complexity)
116 - return
117 - if origin is Union:
118 - types_ = []
119 -- for type_ in self.type_.__args__:
120 -+ for type_ in get_args(self.type_):
121 - if type_ is NoneType:
122 - if self.required is Undefined:
123 - self.required = False
124 -@@ -444,9 +446,9 @@ def _type_analysis(self) -> None: # noqa: C901 (ignore complexity)
125 - if issubclass(origin, Tuple): # type: ignore
126 - self.shape = SHAPE_TUPLE
127 - self.sub_fields = []
128 -- for i, t in enumerate(self.type_.__args__):
129 -+ for i, t in enumerate(get_args(self.type_)):
130 - if t is Ellipsis:
131 -- self.type_ = self.type_.__args__[0]
132 -+ self.type_ = get_args(self.type_)[0]
133 - self.shape = SHAPE_TUPLE_ELLIPSIS
134 - return
135 - self.sub_fields.append(self._create_sub_type(t, f'{self.name}_{i}'))
136 -@@ -460,7 +462,7 @@ def _type_analysis(self) -> None: # noqa: C901 (ignore complexity)
137 - {f'list_{i}': Validator(validator, pre=True) for i, validator in enumerate(get_validators())}
138 - )
139 -
140 -- self.type_ = self.type_.__args__[0]
141 -+ self.type_ = get_args(self.type_)[0]
142 - self.shape = SHAPE_LIST
143 - elif issubclass(origin, Set):
144 - # Create self validators
145 -@@ -470,22 +472,22 @@ def _type_analysis(self) -> None: # noqa: C901 (ignore complexity)
146 - {f'set_{i}': Validator(validator, pre=True) for i, validator in enumerate(get_validators())}
147 - )
148 -
149 -- self.type_ = self.type_.__args__[0]
150 -+ self.type_ = get_args(self.type_)[0]
151 - self.shape = SHAPE_SET
152 - elif issubclass(origin, FrozenSet):
153 -- self.type_ = self.type_.__args__[0]
154 -+ self.type_ = get_args(self.type_)[0]
155 - self.shape = SHAPE_FROZENSET
156 - elif issubclass(origin, Sequence):
157 -- self.type_ = self.type_.__args__[0]
158 -+ self.type_ = get_args(self.type_)[0]
159 - self.shape = SHAPE_SEQUENCE
160 - elif issubclass(origin, Mapping):
161 -- self.key_field = self._create_sub_type(self.type_.__args__[0], 'key_' + self.name, for_keys=True)
162 -- self.type_ = self.type_.__args__[1]
163 -+ self.key_field = self._create_sub_type(get_args(self.type_)[0], 'key_' + self.name, for_keys=True)
164 -+ self.type_ = get_args(self.type_)[1]
165 - self.shape = SHAPE_MAPPING
166 - # Equality check as almost everything inherits form Iterable, including str
167 - # check for Iterable and CollectionsIterable, as it could receive one even when declared with the other
168 - elif origin in {Iterable, CollectionsIterable}:
169 -- self.type_ = self.type_.__args__[0]
170 -+ self.type_ = get_args(self.type_)[0]
171 - self.shape = SHAPE_ITERABLE
172 - self.sub_fields = [self._create_sub_type(self.type_, f'{self.name}_type')]
173 - elif issubclass(origin, Type): # type: ignore
174 -@@ -494,7 +496,7 @@ def _type_analysis(self) -> None: # noqa: C901 (ignore complexity)
175 - # Is a Pydantic-compatible generic that handles itself
176 - # or we have arbitrary_types_allowed = True
177 - self.shape = SHAPE_GENERIC
178 -- self.sub_fields = [self._create_sub_type(t, f'{self.name}_{i}') for i, t in enumerate(self.type_.__args__)]
179 -+ self.sub_fields = [self._create_sub_type(t, f'{self.name}_{i}') for i, t in enumerate(get_args(self.type_))]
180 - self.type_ = origin
181 - return
182 - else:
183 -diff --git a/pydantic/generics.py b/pydantic/generics.py
184 -index 64562227d..0a5e75401 100644
185 ---- a/pydantic/generics.py
186 -+++ b/pydantic/generics.py
187 -@@ -3,6 +3,7 @@
188 - from .class_validators import gather_all_validators
189 - from .fields import FieldInfo, ModelField
190 - from .main import BaseModel, create_model
191 -+from .typing import get_origin
192 - from .utils import lenient_issubclass
193 -
194 - _generic_types_cache: Dict[Tuple[Type[Any], Union[Any, Tuple[Any, ...]]], Type[BaseModel]] = {}
195 -@@ -37,7 +38,7 @@ def __class_getitem__(cls: Type[GenericModelT], params: Union[Type[Any], Tuple[T
196 - check_parameters_count(cls, params)
197 - typevars_map: Dict[TypeVarType, Type[Any]] = dict(zip(cls.__parameters__, params))
198 - type_hints = get_type_hints(cls).items()
199 -- instance_type_hints = {k: v for k, v in type_hints if getattr(v, '__origin__', None) is not ClassVar}
200 -+ instance_type_hints = {k: v for k, v in type_hints if get_origin(v) is not ClassVar}
201 - concrete_type_hints: Dict[str, Type[Any]] = {
202 - k: resolve_type_hint(v, typevars_map) for k, v in instance_type_hints.items()
203 - }
204 -@@ -79,7 +80,7 @@ def __concrete_name__(cls: Type[Any], params: Tuple[Type[Any], ...]) -> str:
205 -
206 -
207 - def resolve_type_hint(type_: Any, typevars_map: Dict[Any, Any]) -> Type[Any]:
208 -- if hasattr(type_, '__origin__') and getattr(type_, '__parameters__', None):
209 -+ if get_origin(type_) and getattr(type_, '__parameters__', None):
210 - concrete_type_args = tuple([typevars_map[x] for x in type_.__parameters__])
211 - return type_[concrete_type_args]
212 - return typevars_map.get(type_, type_)
213 -diff --git a/pydantic/main.py b/pydantic/main.py
214 -index c872f1e3b..87299b645 100644
215 ---- a/pydantic/main.py
216 -+++ b/pydantic/main.py
217 -@@ -33,7 +33,7 @@
218 - from .parse import Protocol, load_file, load_str_bytes
219 - from .schema import model_schema
220 - from .types import PyObject, StrBytes
221 --from .typing import AnyCallable, ForwardRef, is_classvar, resolve_annotations, update_field_forward_refs
222 -+from .typing import AnyCallable, ForwardRef, get_origin, is_classvar, resolve_annotations, update_field_forward_refs
223 - from .utils import (
224 - ClassAttribute,
225 - GetterDict,
226 -@@ -256,7 +256,7 @@ def __new__(mcs, name, bases, namespace, **kwargs): # noqa C901
227 - if (
228 - isinstance(value, untouched_types)
229 - and ann_type != PyObject
230 -- and not lenient_issubclass(getattr(ann_type, '__origin__', None), Type)
231 -+ and not lenient_issubclass(get_origin(ann_type), Type)
232 - ):
233 - continue
234 - fields[ann_name] = inferred = ModelField.infer(
235 -diff --git a/pydantic/schema.py b/pydantic/schema.py
236 -index 27c66b2bd..4f6258ab1 100644
237 ---- a/pydantic/schema.py
238 -+++ b/pydantic/schema.py
239 -@@ -55,7 +55,7 @@
240 - conset,
241 - constr,
242 - )
243 --from .typing import ForwardRef, Literal, is_callable_type, is_literal_type, literal_values
244 -+from .typing import ForwardRef, Literal, get_args, get_origin, is_callable_type, is_literal_type, literal_values
245 - from .utils import get_model, lenient_issubclass, sequence_like
246 -
247 - if TYPE_CHECKING:
248 -@@ -803,9 +803,9 @@ def go(type_: Any) -> Type[Any]:
249 - or lenient_issubclass(type_, (ConstrainedList, ConstrainedSet))
250 - ):
251 - return type_
252 -- origin = getattr(type_, '__origin__', None)
253 -+ origin = get_origin(type_)
254 - if origin is not None:
255 -- args: Tuple[Any, ...] = type_.__args__
256 -+ args: Tuple[Any, ...] = get_args(type_)
257 - if any(isinstance(a, ForwardRef) for a in args):
258 - # forward refs cause infinite recursion below
259 - return type_
260 -diff --git a/pydantic/typing.py b/pydantic/typing.py
261 -index 070691eeb..729ebd71b 100644
262 ---- a/pydantic/typing.py
263 -+++ b/pydantic/typing.py
264 -@@ -44,12 +44,19 @@ def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
265 - return type_._eval_type(globalns, localns)
266 -
267 -
268 --else:
269 -+elif sys.version_info < (3, 9):
270 -
271 - def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
272 - return type_._evaluate(globalns, localns)
273 -
274 -
275 -+else:
276 -+
277 -+ # TODO: remove the pragma: no cover once we can run CI on python 3.9
278 -+ def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any: # pragma: no cover
279 -+ return type_._evaluate(globalns, localns, set())
280 -+
281 -+
282 - if sys.version_info < (3, 7):
283 - from typing import Callable as Callable
284 -
285 -@@ -70,8 +77,50 @@ def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
286 - from typing_extensions import Literal
287 - except ImportError:
288 - Literal = None
289 -+
290 -+ def get_args(t: Type[Any]) -> Tuple[Any, ...]:
291 -+ return getattr(t, '__args__', ())
292 -+
293 -+ def get_origin(t: Type[Any]) -> Optional[Type[Any]]:
294 -+ return getattr(t, '__origin__', None)
295 -+
296 -+
297 - else:
298 -- from typing import Literal
299 -+ from typing import Literal, get_args as typing_get_args, get_origin as typing_get_origin
300 -+
301 -+ def get_origin(tp: Type[Any]) -> Type[Any]:
302 -+ return typing_get_origin(tp) or getattr(tp, '__origin__', None)
303 -+
304 -+ def generic_get_args(tp: Type[Any]) -> Tuple[Any, ...]:
305 -+ """
306 -+ In python 3.9, `typing.Dict`, `typing.List`, ...
307 -+ do have an empty `__args__` by default (instead of the generic ~T for example).
308 -+ In order to still support `Dict` for example and consider it as `Dict[Any, Any]`,
309 -+ we retrieve the `_nparams` value that tells us how many parameters it needs.
310 -+ """
311 -+ # TODO: remove the pragma: no cover once we can run CI on python 3.9
312 -+ if hasattr(tp, '_nparams'): # pragma: no cover
313 -+ return (Any,) * tp._nparams
314 -+ return ()
315 -+
316 -+ def get_args(tp: Type[Any]) -> Tuple[Any, ...]:
317 -+ """Get type arguments with all substitutions performed.
318 -+
319 -+ For unions, basic simplifications used by Union constructor are performed.
320 -+ Examples::
321 -+ get_args(Dict[str, int]) == (str, int)
322 -+ get_args(int) == ()
323 -+ get_args(Union[int, Union[T, int], str][int]) == (int, str)
324 -+ get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int])
325 -+ get_args(Callable[[], T][int]) == ([], int)
326 -+ """
327 -+ try:
328 -+ args = typing_get_args(tp)
329 -+ # TODO: remove the pragma: no cover once we can run CI on python 3.9
330 -+ except IndexError: # pragma: no cover
331 -+ args = ()
332 -+ return args or getattr(tp, '__args__', ()) or generic_get_args(tp)
333 -+
334 -
335 - if TYPE_CHECKING:
336 - from .fields import ModelField
337 -@@ -115,6 +164,8 @@ def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
338 - 'CallableGenerator',
339 - 'ReprArgs',
340 - 'CallableGenerator',
341 -+ 'get_args',
342 -+ 'get_origin',
343 - )
344 -
345 -
346 -@@ -167,16 +218,16 @@ def resolve_annotations(raw_annotations: Dict[str, Type[Any]], module_name: Opti
347 -
348 -
349 - def is_callable_type(type_: Type[Any]) -> bool:
350 -- return type_ is Callable or getattr(type_, '__origin__', None) is Callable
351 -+ return type_ is Callable or get_origin(type_) is Callable
352 -
353 -
354 - if sys.version_info >= (3, 7):
355 -
356 - def is_literal_type(type_: Type[Any]) -> bool:
357 -- return Literal is not None and getattr(type_, '__origin__', None) is Literal
358 -+ return Literal is not None and get_origin(type_) is Literal
359 -
360 - def literal_values(type_: Type[Any]) -> Tuple[Any, ...]:
361 -- return type_.__args__
362 -+ return get_args(type_)
363 -
364 -
365 - else:
366 -@@ -217,12 +268,15 @@ def new_type_supertype(type_: Type[Any]) -> Type[Any]:
367 - return type_
368 -
369 -
370 --def _check_classvar(v: Type[Any]) -> bool:
371 -+def _check_classvar(v: Optional[Type[Any]]) -> bool:
372 -+ if v is None:
373 -+ return False
374 -+
375 - return v.__class__ == ClassVar.__class__ and (sys.version_info < (3, 7) or getattr(v, '_name', None) == 'ClassVar')
376 -
377 -
378 - def is_classvar(ann_type: Type[Any]) -> bool:
379 -- return _check_classvar(ann_type) or _check_classvar(getattr(ann_type, '__origin__', None))
380 -+ return _check_classvar(ann_type) or _check_classvar(get_origin(ann_type))
381 -
382 -
383 - def update_field_forward_refs(field: 'ModelField', globalns: Any, localns: Any) -> None:
384 -@@ -243,13 +297,13 @@ def get_class(type_: Type[Any]) -> Union[None, bool, Type[Any]]:
385 - without brackets. Otherwise returns None.
386 - """
387 - try:
388 -- origin = getattr(type_, '__origin__')
389 -+ origin = get_origin(type_)
390 - if origin is None: # Python 3.6
391 - origin = type_
392 - if issubclass(origin, Type): # type: ignore
393 -- if type_.__args__ is None or not isinstance(type_.__args__[0], type):
394 -+ if not get_args(type_) or not isinstance(get_args(type_)[0], type):
395 - return True
396 -- return type_.__args__[0]
397 -- except AttributeError:
398 -+ return get_args(type_)[0]
399 -+ except (AttributeError, TypeError):
400 - pass
401 - return None
402
403 diff --git a/dev-python/pydantic/pydantic-1.6.1.ebuild b/dev-python/pydantic/pydantic-1.6.1.ebuild
404 deleted file mode 100644
405 index 584f26cc9ec..00000000000
406 --- a/dev-python/pydantic/pydantic-1.6.1.ebuild
407 +++ /dev/null
408 @@ -1,38 +0,0 @@
409 -# Copyright 1999-2020 Gentoo Authors
410 -# Distributed under the terms of the GNU General Public License v2
411 -
412 -EAPI=7
413 -
414 -# At the moment, PyPy3 doesn't have a dataclasses module
415 -# It can probably be added when PyPy3.7 is stable
416 -PYTHON_COMPAT=( python3_{7..9} )
417 -
418 -inherit distutils-r1
419 -
420 -DESCRIPTION="Data parsing and validation using Python type hints"
421 -HOMEPAGE="https://github.com/samuelcolvin/pydantic"
422 -# No tests on PyPI: https://github.com/samuelcolvin/pydantic/pull/1976
423 -SRC_URI="https://github.com/samuelcolvin/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
424 -
425 -LICENSE="MIT"
426 -SLOT="0"
427 -KEYWORDS="~amd64 ~x86"
428 -
429 -BDEPEND="
430 - dev-python/cython[${PYTHON_USEDEP}]
431 -"
432 -
433 -PATCHES=(
434 - # https://github.com/samuelcolvin/pydantic/pull/1977
435 - "${FILESDIR}/${P}-fix-tests.patch"
436 - # https://github.com/samuelcolvin/pydantic/pull/1844
437 - "${FILESDIR}/${P}-py39.patch"
438 -)
439 -
440 -distutils_enable_tests pytest
441 -
442 -python_prepare_all() {
443 - # So we don't need pytest-timeout
444 - sed -i '/^timeout = /d' setup.cfg || die
445 - distutils-r1_python_prepare_all
446 -}