Hello community,
here is the log from the commit of package python-pydantic for openSUSE:Factory
checked in at 2020-06-10 00:53:49
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pydantic (Old)
and /work/SRC/openSUSE:Factory/.python-pydantic.new.3606 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pydantic"
Wed Jun 10 00:53:49 2020 rev:4 rq:813030 version:1.5.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pydantic/python-pydantic.changes
2020-04-21 13:05:44.560222974 +0200
+++
/work/SRC/openSUSE:Factory/.python-pydantic.new.3606/python-pydantic.changes
2020-06-10 00:54:08.699840276 +0200
@@ -1,0 +2,7 @@
+Tue Jun 9 19:24:27 UTC 2020 - Dirk Mueller <[email protected]>
+
+- update to 1.5.1
+ * Signature generation with `extra: allow` never uses a field name, #1418 by
@prettywood
+ * Avoid mutating `Field` default value, #1412 by @prettywood
+
+-------------------------------------------------------------------
Old:
----
v1.5.tar.gz
New:
----
v1.5.1.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pydantic.spec ++++++
--- /var/tmp/diff_new_pack.B55SyM/_old 2020-06-10 00:54:10.243844272 +0200
+++ /var/tmp/diff_new_pack.B55SyM/_new 2020-06-10 00:54:10.247844282 +0200
@@ -20,14 +20,14 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-pydantic
-Version: 1.5
+Version: 1.5.1
Release: 0
Summary: Data validation and settings management using python type
hinting
License: MIT
Group: Development/Languages/Python
URL: https://github.com/samuelcolvin/pydantic
Source:
https://github.com/samuelcolvin/pydantic/archive/v%{version}.tar.gz
-BuildRequires: %{python_module pytest}
+BuildRequires: %{python_module pytest < 5}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
++++++ v1.5.tar.gz -> v1.5.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.5/HISTORY.md new/pydantic-1.5.1/HISTORY.md
--- old/pydantic-1.5/HISTORY.md 2020-04-18 19:08:28.000000000 +0200
+++ new/pydantic-1.5.1/HISTORY.md 2020-04-23 14:43:34.000000000 +0200
@@ -1,3 +1,8 @@
+## v1.5.1 (2020-04-23)
+
+* Signature generation with `extra: allow` never uses a field name, #1418 by
@prettywood
+* Avoid mutating `Field` default value, #1412 by @prettywood
+
## v1.5 (2020-04-18)
* Make includes/excludes arguments for `.dict()`, `._iter()`, ..., immutable,
#1404 by @AlexECX
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.5/docs/requirements.txt
new/pydantic-1.5.1/docs/requirements.txt
--- old/pydantic-1.5/docs/requirements.txt 2020-04-18 19:08:28.000000000
+0200
+++ new/pydantic-1.5.1/docs/requirements.txt 2020-04-23 14:43:34.000000000
+0200
@@ -2,7 +2,7 @@
mkdocs==1.1.0
markdown==3.2.1
mkdocs-exclude==1.0.2
-mkdocs-material==5.1
+mkdocs-material==5.1.1
markdown-include==0.5.1
pygments==2.6.1
sqlalchemy # pyup: ignore
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.5/pydantic/fields.py
new/pydantic-1.5.1/pydantic/fields.py
--- old/pydantic-1.5/pydantic/fields.py 2020-04-18 19:08:28.000000000 +0200
+++ new/pydantic-1.5.1/pydantic/fields.py 2020-04-23 14:43:34.000000000
+0200
@@ -302,7 +302,7 @@
required: 'BoolUndefined' = Undefined
if value is Required:
required = True
- field_info.default = None
+ value = None
elif value is not Undefined:
required = False
field_info.alias = field_info.alias or
field_info_from_config.get('alias')
@@ -312,7 +312,7 @@
type_=annotation,
alias=field_info.alias,
class_validators=class_validators,
- default=field_info.default,
+ default=value,
default_factory=field_info.default_factory,
required=required,
model_config=config,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.5/pydantic/utils.py
new/pydantic-1.5.1/pydantic/utils.py
--- old/pydantic-1.5/pydantic/utils.py 2020-04-18 19:08:28.000000000 +0200
+++ new/pydantic-1.5.1/pydantic/utils.py 2020-04-23 14:43:34.000000000
+0200
@@ -174,13 +174,31 @@
# TODO: replace annotation with actual expected types once #1055
solved
kwargs = {'default': field.default} if not field.required else {}
- merged_params[param_name] = Parameter(param_name,
Parameter.KEYWORD_ONLY, annotation=field.type_, **kwargs)
+ merged_params[param_name] = Parameter(
+ param_name, Parameter.KEYWORD_ONLY,
annotation=field.outer_type_, **kwargs
+ )
if config.extra is config.extra.allow:
use_var_kw = True
if var_kw and use_var_kw:
- merged_params[var_kw.name] = var_kw
+ # Make sure the parameter for extra kwargs
+ # does not have the same name as a field
+ default_model_signature = [
+ ('__pydantic_self__', Parameter.POSITIONAL_OR_KEYWORD),
+ ('data', Parameter.VAR_KEYWORD),
+ ]
+ if [(p.name, p.kind) for p in present_params] ==
default_model_signature:
+ # if this is the standard model signature, use extra_data as the
extra args name
+ var_kw_name = 'extra_data'
+ else:
+ # else start from var_kw
+ var_kw_name = var_kw.name
+
+ # generate a name that's definitely unique
+ while var_kw_name in fields:
+ var_kw_name += '_'
+ merged_params[var_kw_name] = var_kw.replace(name=var_kw_name)
return Signature(parameters=list(merged_params.values()),
return_annotation=None)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.5/pydantic/version.py
new/pydantic-1.5.1/pydantic/version.py
--- old/pydantic-1.5/pydantic/version.py 2020-04-18 19:08:28.000000000
+0200
+++ new/pydantic-1.5.1/pydantic/version.py 2020-04-23 14:43:34.000000000
+0200
@@ -1,6 +1,6 @@
__all__ = 'VERSION', 'version_info'
-VERSION = '1.5'
+VERSION = '1.5.1'
def version_info() -> str:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.5/tests/requirements.txt
new/pydantic-1.5.1/tests/requirements.txt
--- old/pydantic-1.5/tests/requirements.txt 2020-04-18 19:08:28.000000000
+0200
+++ new/pydantic-1.5.1/tests/requirements.txt 2020-04-23 14:43:34.000000000
+0200
@@ -9,6 +9,6 @@
pyflakes==2.1.1
pytest==5.3.5
pytest-cov==2.8.1
-pytest-mock==3
+pytest-mock==3.1.0
pytest-sugar==0.9.2
twine==3.1.1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.5/tests/test_main.py
new/pydantic-1.5.1/tests/test_main.py
--- old/pydantic-1.5/tests/test_main.py 2020-04-18 19:08:28.000000000 +0200
+++ new/pydantic-1.5.1/tests/test_main.py 2020-04-23 14:43:34.000000000
+0200
@@ -1095,3 +1095,18 @@
assert f.foo is None
assert f.bar is None
assert f.baz is None
+
+
+def test_reuse_same_field():
+ required_field = Field(...)
+
+ class Model1(BaseModel):
+ required: str = required_field
+
+ class Model2(BaseModel):
+ required: str = required_field
+
+ with pytest.raises(ValidationError):
+ Model1.parse_obj({})
+ with pytest.raises(ValidationError):
+ Model2.parse_obj({})
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.5/tests/test_model_signature.py
new/pydantic-1.5.1/tests/test_model_signature.py
--- old/pydantic-1.5/tests/test_model_signature.py 2020-04-18
19:08:28.000000000 +0200
+++ new/pydantic-1.5.1/tests/test_model_signature.py 2020-04-23
14:43:34.000000000 +0200
@@ -71,7 +71,7 @@
)
assert _equals(str(signature(model)), '(*, valid_identifier: int = 123,
yeah: int = 0) -> None')
model = create_model('Model', **{'123 invalid identifier!': 123, '!':
Field(0, alias='yeah')})
- assert _equals(str(signature(model)), '(*, yeah: int = 0, **data: Any) ->
None')
+ assert _equals(str(signature(model)), '(*, yeah: int = 0, **extra_data:
Any) -> None')
def test_use_field_name():
@@ -82,3 +82,47 @@
allow_population_by_field_name = True
assert _equals(str(signature(Foo)), '(*, foo: str) -> None')
+
+
+def test_extra_allow_no_conflict():
+ class Model(BaseModel):
+ spam: str
+
+ class Config:
+ extra = Extra.allow
+
+ assert _equals(str(signature(Model)), '(*, spam: str, **extra_data: Any)
-> None')
+
+
+def test_extra_allow_conflict():
+ class Model(BaseModel):
+ extra_data: str
+
+ class Config:
+ extra = Extra.allow
+
+ assert _equals(str(signature(Model)), '(*, extra_data: str, **extra_data_:
Any) -> None')
+
+
+def test_extra_allow_conflict_twice():
+ class Model(BaseModel):
+ extra_data: str
+ extra_data_: str
+
+ class Config:
+ extra = Extra.allow
+
+ assert _equals(str(signature(Model)), '(*, extra_data: str, extra_data_:
str, **extra_data__: Any) -> None')
+
+
+def test_extra_allow_conflict_custom_signature():
+ class Model(BaseModel):
+ extra_data: int
+
+ def __init__(self, extra_data: int = 1, **foobar: Any):
+ super().__init__(extra_data=extra_data, **foobar)
+
+ class Config:
+ extra = Extra.allow
+
+ assert _equals(str(signature(Model)), '(extra_data: int = 1, **foobar:
Any) -> None')