Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-pydantic for openSUSE:Factory
checked in at 2023-05-26 20:14:59
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pydantic (Old)
and /work/SRC/openSUSE:Factory/.python-pydantic.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pydantic"
Fri May 26 20:14:59 2023 rev:18 rq:1088976 version:1.10.8
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pydantic/python-pydantic.changes
2023-03-29 23:26:42.859319426 +0200
+++
/work/SRC/openSUSE:Factory/.python-pydantic.new.1533/python-pydantic.changes
2023-05-26 20:15:03.504114218 +0200
@@ -1,0 +2,15 @@
+Thu May 25 07:32:32 UTC 2023 - Daniel Garcia <[email protected]>
+
+- Update to v1.10.8
+ * Fix a bug in `Literal` usage with `typing-extension==4.6.0`, #5826
+ by @hramezani
+ * This solves the (closed) issue #3849 where aliased fields that use
+ discriminated union fail to validate when the data contains the
+ non-aliased field name, #5736 by @benwah
+ * Update email-validator dependency to >=2.0.0post2, #5627 by
+ @adriangb
+ * update `AnyClassMethod` for changes in
+ [python/typeshed#9771](https://github.com/python/typeshed/issues/9771),
+ #5505 by @ITProKyle
+
+-------------------------------------------------------------------
Old:
----
pydantic-1.10.7.tar.gz
New:
----
pydantic-1.10.8.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pydantic.spec ++++++
--- /var/tmp/diff_new_pack.NSQ8vz/_old 2023-05-26 20:15:03.996117151 +0200
+++ /var/tmp/diff_new_pack.NSQ8vz/_new 2023-05-26 20:15:04.000117174 +0200
@@ -17,9 +17,10 @@
#
+%{?sle15_python_module_pythons}
%define skip_python2 1
Name: python-pydantic
-Version: 1.10.7
+Version: 1.10.8
Release: 0
Summary: Data validation and settings management using python type
hinting
License: MIT
++++++ pydantic-1.10.7.tar.gz -> pydantic-1.10.8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/.github/workflows/ci.yml
new/pydantic-1.10.8/.github/workflows/ci.yml
--- old/pydantic-1.10.7/.github/workflows/ci.yml 2023-03-22
20:29:23.000000000 +0100
+++ new/pydantic-1.10.8/.github/workflows/ci.yml 2023-05-23
19:13:55.000000000 +0200
@@ -452,57 +452,71 @@
ls dist/*cp310-manylinux*x86_64.whl | head -n 1
python -m zipfile --list `ls dist/*cp310-manylinux*x86_64.whl | head
-n 1`
- deploy:
- name: Deploy
- needs:
- - check
- - build
- if: "success() && startsWith(github.ref, 'refs/tags/')"
+ publish_docs:
+ needs: [check]
+ if: "success() && (github.ref == 'refs/heads/1.10.X-fixes' ||
startsWith(github.ref, 'refs/tags/'))"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - name: checkout docs-site
+ uses: actions/checkout@v3
+ with:
+ ref: docs-site
+
+ - name: checkout current branch
+ uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v4
with:
python-version: '3.10'
+ - name: install
+ run: make install-docs
+
+ - name: Set git credentials
+ run: |
+ git config --global user.name "${{ github.actor }}"
+ git config --global user.email "${{ github.actor
}}@users.noreply.github.com"
+
+ - run: make docs
+
+ - run: mike deploy -b docs-site dev-v1 --push
+ if: github.ref == 'refs/heads/1.10.X-fixes'
+
+ - name: check version
+ if: "startsWith(github.ref, 'refs/tags/')"
+ id: check-version
+ uses: samuelcolvin/[email protected]
+ with:
+ version_file_path: 'pydantic/version.py'
+
+ # need to remove "latest" once V2 is released!
+ - run: mike deploy -b docs-site ${{
steps.check-version.outputs.VERSION_MAJOR_MINOR }} latest --update-aliases
--push
+ if: "startsWith(github.ref, 'refs/tags/') &&
!fromJSON(steps.check-version.outputs.IS_PRERELEASE)"
+
+ release:
+ needs: [check]
+ if: "success() && startsWith(github.ref, 'refs/tags/')"
+ runs-on: ubuntu-latest
+ environment: release
+
+ permissions:
+ id-token: write
+
+ steps:
+ - uses: actions/checkout@v3
+
- name: get dist artifacts
uses: actions/download-artifact@v3
with:
name: pypi_files
path: dist
- - name: get docs
- uses: actions/download-artifact@v3
+ - name: check version
+ uses: samuelcolvin/[email protected]
with:
- name: docs
- path: site
-
- - name: install
- run: pip install -U twine packaging
+ version_file_path: pydantic/version.py
- - name: twine check
- run: |
- twine check dist/*
- ls -lh dist
-
- - name: check tag
- id: check-tag
- run: ./tests/check_tag.py
-
- - name: upload to pypi
- run: twine upload dist/*
- env:
- TWINE_USERNAME: __token__
- TWINE_PASSWORD: ${{ secrets.pypi_token }}
-
- - name: publish docs
- if: '!fromJSON(steps.check-tag.outputs.IS_PRERELEASE)'
- uses: cloudflare/[email protected]
- with:
- apiToken: ${{ secrets.cloudflare_api_token }}
- command: pages publish --project-name=pydantic-docs --branch=main
site
- env:
- CLOUDFLARE_ACCOUNT_ID: ${{ secrets.cloudflare_account_id }}
+ - name: Upload package to PyPI
+ uses: pypa/gh-action-pypi-publish@release/v1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/HISTORY.md
new/pydantic-1.10.8/HISTORY.md
--- old/pydantic-1.10.7/HISTORY.md 2023-03-22 20:29:23.000000000 +0100
+++ new/pydantic-1.10.8/HISTORY.md 2023-05-23 19:13:55.000000000 +0200
@@ -1,3 +1,16 @@
+## v1.10.8 (2023-05-23)
+
+* Fix a bug in `Literal` usage with `typing-extension==4.6.0`, #5826 by
@hramezani
+* This solves the (closed) issue #3849 where aliased fields that use
discriminated union fail to validate when the data contains the non-aliased
field name, #5736 by @benwah
+* Update email-validator dependency to >=2.0.0post2, #5627 by @adriangb
+* update `AnyClassMethod` for changes in
[python/typeshed#9771](https://github.com/python/typeshed/issues/9771), #5505
by @ITProKyle
+
+## v2.0a1 (2023-04-03)
+
+First pre-release of Pydantic V2!
+
+See [this post](https://docs.pydantic.dev/blog/pydantic-v2-alpha/) for more
details.
+
## v1.10.7 (2023-03-22)
* Fix creating schema from model using `ConstrainedStr` with `regex` as dict
key, #5223 by @matejetz
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/build-docs.sh
new/pydantic-1.10.8/build-docs.sh
--- old/pydantic-1.10.7/build-docs.sh 1970-01-01 01:00:00.000000000 +0100
+++ new/pydantic-1.10.8/build-docs.sh 2023-05-23 19:13:55.000000000 +0200
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+# This script is used to build the documentation on CloudFlare Pages, this is
just used for build previews
+# A different script with the same name exists on the `docs-site` branch
(where pre-built docs live).
+
+set -e
+set -x
+
+python3 -V
+
+make install-docs
+
+make docs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/docs/blog/pydantic-v2-alpha.md
new/pydantic-1.10.8/docs/blog/pydantic-v2-alpha.md
--- old/pydantic-1.10.7/docs/blog/pydantic-v2-alpha.md 1970-01-01
01:00:00.000000000 +0100
+++ new/pydantic-1.10.8/docs/blog/pydantic-v2-alpha.md 2023-05-23
19:13:55.000000000 +0200
@@ -0,0 +1,199 @@
+# Pydantic V2 Pre Release
+
+<aside class="blog" markdown>
+
+<div markdown>
+ **Terrence Dorsey & Samuel Colvin** •
+ [:material-github:](https://github.com/pydantic) •
+ [:material-twitter:](https://twitter.com/pydantic) •
+ :octicons-calendar-24: April 3, 2023 •
+ :octicons-clock-24: 8 min read
+</div>
+</aside>
+
+---
+
+We're excited to announce the first alpha release of Pydantic V2!
+
+This first Pydantic V2 alpha is no April Fool's joke — for a start we
missed our April 1st target date :cry:.
+After a year's work, we invite you to explore the improvements we've made and
give us your feedback.
+We look forward to hearing your thoughts and working together to improve the
library.
+
+For many of you, Pydantic is already a key part of your Python toolkit and
needs no introduction —
+we hope you'll find the improvements and additions in Pydantic V2 useful.
+
+If you're new to Pydantic: Pydantic is an open-source Python library that
provides powerful data parsing and validation —
+including type coercion and useful error messages when typing issues arise
— and settings management capabilities.
+See [the docs](/) for examples of Pydantic at work.
+
+## Getting started with the Pydantic V2 alpha
+
+Your feedback will be a critical part of ensuring that we have made the right
tradeoffs with the API changes in V2.
+
+To get started with the Pydantic V2 alpha, install it from PyPI.
+We recommend using a virtual environment to isolate your testing environment:
+
+```bash
+pip install --pre -U "pydantic>=2.0a1"
+```
+
+Note that there are still some rough edges and incomplete features, and while
trying out the Pydantic V2 alpha releases you may experience errors.
+We encourage you to try out the alpha releases in a test environment and not
in production.
+Some features are still in development, and we will continue to make changes
to the API.
+
+If you do encounter any issues, please [create an issue in
GitHub](https://github.com/pydantic/pydantic/issues) using the `bug V2` label.
+This will help us to actively monitor and track errors, and to continue to
improve the libraryâs performance.
+
+This will be the first of several upcoming alpha releases. As you evaluate our
changes and enhancements,
+we encourage you to share your feedback with us.
+
+Please let us know:
+
+* If you don't like the changes, so we can make sure Pydantic remains a
library you enjoy using.
+* If this breaks your usage of Pydantic so we can fix it, or at least describe
a migration path.
+
+Thank you for your support, and we look forward to your feedback.
+
+---
+
+## Headlines
+
+Here are some of the most interesting new features in the current Pydantic V2
alpha release.
+For background on plans behind these features, see the earlier [Pydantic V2
Plan](/blog/pydantic-v2/) blog post.
+
+The biggest change to Pydantic V2 is
[`pydantic-core`](https://github.com/pydantic/pydantic-core) —
+all validation logic has been rewritten in Rust and moved to a separate
package, `pydantic-core`.
+This has a number of big advantages:
+
+* **Performance** - Pydantic V2 is 5-50x faster than Pydantic V1.
+* **Safety & maintainability** - We've made changes to the architecture that
we think will help us maintain Pydantic V2 with far fewer bugs in the long term.
+
+With the use of `pydantic-core`, the majority of the logic in the Pydantic
library is dedicated to generating
+"pydantic core schema" — the schema used define the behaviour of the
new, high-performance `pydantic-core` validators and serializers.
+
+### Ready for experimentation
+
+* **BaseModel** - the core of validation in Pydantic V1 remains, albeit with
new method names.
+* **Dataclasses** - Pydantic dataclasses are improved and ready to test.
+* **Serialization** - dumping/serialization/marshalling is significantly more
flexible, and ready to test.
+* **Strict mode** - one of the biggest additions in Pydantic V2 is strict
mode, which is ready to test.
+* **JSON Schema** - generation of JSON Schema is much improved and ready to
test.
+* **Generic Models** - are much improved and ready to test.
+* **Recursive Models** - and validation of recursive data structures is much
improved and ready to test.
+* **Custom Types** - custom types have a new interface and are ready to test.
+* **Custom Field Modifiers** - used via `Annotated[]` are working and in use
in Pydantic itself.
+* **Validation without a BaseModel** - the new `AnalyzedType` class allows
validation without the need for a `BaseModel` class, and it's ready to test.
+* **TypedDict** - we now have full support for `TypedDict` via `AnalyzedType`,
it's ready to test.
+
+### Still under construction
+
+* **Documentation** - we're working hard on full documentation for V2, but
it's not ready yet.
+* **Conversion Table** - a big addition to the documentation will be a
conversion table showing how types are coerced, this is a WIP.
+* **BaseSettings** - `BaseSettings` will move to a separate
`pydantic-settings` package, it's not yet ready to test.
+ **Notice:** since `pydantic-settings` is not yet ready to release, there's
no support for `BaseSettings` in the first alpha release.
+* **validate_arguments** - the `validate_arguments` decorator remains and is
working, but hasn't been updated yet.
+* **Hypothesis Plugin** - the Hypothesis plugin is yet to be updated.
+* **computed fields** - we know a lot of people are waiting for this, we will
include it in Pydantic V2.
+* **Error messages** - could use some love, and links to docs in error
messages are still to be added.
+* **Migration Guide** - we have some pointers below, but this needs completing.
+
+## Migration Guide
+
+**Please note:** this is just the beginning of a migration guide. We'll work
hard up to the final release to prepare
+a full migration guide, but for now the following pointers should be some help
while experimenting with V2.
+
+### Changes to BaseModel
+
+* Various method names have been changed; `BaseModel` methods all start with
`model_` now.
+ Where possible, we have retained the old method names to help ease
migration, but calling them will result in `DeprecationWarning`s.
+ * Some of the built-in data loading functionality has been slated for
removal.
+ In particular, `parse_raw` and `parse_file` are now deprecated. You should
load the data and then pass it to `model_validate`.
+* The `from_orm` method has been removed; you can now just use
`model_validate` (equivalent to `parse_obj` from Pydantic V1) to achieve
something similar,
+ as long as you've set `from_attributes=True` in the model config.
+* The `__eq__` method has changed for models; models are no longer considered
equal to the dicts.
+* Custom `__init__` overrides won't be called. This should be replaced with a
`@root_validator`.
+* Due to inconsistency with the rest of the library, we have removed the
special behavior of models
+ using the `__root__` field, and have disallowed the use of an attribute with
this name to prevent confusion.
+ However, you can achieve equivalent behavior with a "standard" field name
through the use of `@root_validator`,
+ `@model_serializer`, and `__pydantic_modify_json_schema__`. You can see an
example of this
+
[here](https://github.com/pydantic/pydantic/blob/2b9459f20d094a46fa3093b43c34444240f03646/tests/test_parse.py#L95-L113).
+
+### Changes to Pydantic Dataclasses
+
+* The `__post_init__` in Pydantic dataclasses will now be called after
validation, rather than before.
+* We no longer support `extra='allow'` for Pydantic dataclasses, where extra
attributes passed to the initializer would be
+ stored as extra fields on the dataclass. `extra='ignore'` is still supported
for the purposes of allowing extra fields while parsing data; they just aren't
stored.
+* `__post_init_post_parse__` has been removed.
+* Nested dataclasses no longer accept tuples as input, only dict.
+
+### Changes to Config
+
+* To specify config on a model, it is now deprecated to create a class called
`Config` in the namespace of the parent `BaseModel` subclass.
+ Instead, you just need to set a class attribute called `model_config` to be
a dict with the key/value pairs you want to be used as the config.
+
+The following config settings have been removed:
+
+* `allow_mutation`.
+* `error_msg_templates`.
+* `fields` â this was the source of various bugs, so has been removed. You
should be able to use `Annotated` on fields to modify them as desired.
+* `getter_dict` â `orm_mode` has been removed, and this implementation
detail is no longer necessary.
+* `schema_extra` â you should now use the `json_schema_extra` keyword
argument to `pydantic.Field`.
+* `smart_union`.
+* `underscore_attrs_are_private` â the Pydantic V2 behavior is now the same
as if this was always set to `True` in Pydantic V1.
+
+The following config settings have been renamed:
+
+* `allow_population_by_field_name` â `populate_by_name`
+* `anystr_lower` â `str_to_lower`
+* `anystr_strip_whitespace` â `str_strip_whitespace`
+* `anystr_upper` â `str_to_upper`
+* `keep_untouched` â `ignored_types`
+* `max_anystr_length` â `str_max_length`
+* `min_anystr_length` â `str_min_length`
+* `orm_mode` â `from_attributes`
+* `validate_all` â `validate_default`
+
+### Changes to Validators
+
+* Raising a `TypeError` inside a validator no longer produces a
`ValidationError`, but just raises the `TypeError` directly.
+ This was necessary to prevent certain common bugs (such as calling functions
with invalid signatures) from
+ being unintentionally converted into `ValidationError` and displayed to
users.
+ If you really want `TypeError` to be converted to a `ValidationError` you
should use a `try: except:` block that will catch it and do the conversion.
+* `each_item` validators are deprecated and should be replaced with a type
annotation using `Annotated` to apply a validator
+ or with a validator that operates on all items at the top level.
+* Changes to `@validator`-decorated function signatures.
+* The `stricturl` type has been removed.
+* Root validators can no longer be run with `skip_on_failure=False`.
+
+### Changes to Validation of specific types
+
+* Integers outside the valid range of 64 bit integers will cause
`ValidationError`s during parsing.
+ To work around this, use an `IsInstance` validator (more details to come).
+* Subclasses of built-ins won't validate into their subclass types; you'll
need to use an `IsInstance` validator to validate these types.
+
+### Changes to Generic models
+
+* While it does not raise an error at runtime yet, subclass checks for
parametrized generics should no longer be used.
+ These will result in `TypeError`s and we can't promise they will work
forever. However, it will be okay to do subclass checks against
_non-parametrized_ generic models
+
+### Other changes
+
+* `GetterDict` has been removed, as it was just an implementation detail for
`orm_mode`, which has been removed.
+
+### AnalyzedType
+
+Pydantic V1 didn't have good support for validation or serializing
non-`BaseModel`.
+To work with them you had to create a "root" model or use the utility
functions in `pydantic.tools` (`parse_obj_as` and `schema_of`).
+In Pydantic V2 this is _a lot_ easier: the `AnalyzedType` class lets you build
an object that behaves almost like a `BaseModel` class which you can use for a
lot of the use cases of root models and as a complete replacement for
`parse_obj_as` and `schema_of`.
+
+```python
+from typing import List
+from pydantic import AnalyzedType
+
+validator = AnalyzedType(List[int])
+assert validator.validate_python(['1', '2', '3']) == [1, 2, 3]
+print(validator.json_schema())
+# {'type': 'array', 'items': {'type': 'integer'}}
+```
+
+Note that this API is provisional and may change before the final release of
Pydantic V2.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/docs/blog/pydantic-v2.md
new/pydantic-1.10.8/docs/blog/pydantic-v2.md
--- old/pydantic-1.10.7/docs/blog/pydantic-v2.md 2023-03-22
20:29:23.000000000 +0100
+++ new/pydantic-1.10.8/docs/blog/pydantic-v2.md 2023-05-23
19:13:55.000000000 +0200
@@ -16,7 +16,7 @@
Updated late 10 Jul 2022, see
[pydantic#4226](https://github.com/pydantic/pydantic/pull/4226).
Update 30 Dec 2022: **The new release deadline for Pydantic V2 is the end of
Q1 2023**,
-see [pydantic#4887](https://github.com/pydantic/pydantic/issues/4887) for more
details, futher updates
+see [pydantic#4887](https://github.com/pydantic/pydantic/issues/4887) for more
details, further updates
will be posted on that issue.
---
Binary files old/pydantic-1.10.7/docs/img/terrencedorsey.jpg and
new/pydantic-1.10.8/docs/img/terrencedorsey.jpg differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/docs/index.md
new/pydantic-1.10.8/docs/index.md
--- old/pydantic-1.10.7/docs/index.md 2023-03-22 20:29:23.000000000 +0100
+++ new/pydantic-1.10.8/docs/index.md 2023-05-23 19:13:55.000000000 +0200
@@ -13,77 +13,6 @@
Define how data should be in pure, canonical Python; validate it with
*pydantic*.
-## Sponsors
-
-Development of *pydantic* is made possible by the following sponsors:
-
-<div class="sponsors">
- <div>
- <a rel="sponsored" target="_blank" href="https://www.salesforce.com">
- <img src="./sponsor_logos/salesforce.png" alt="Salesforce" />
- <span>Salesforce</span>
- </a>
- </div>
- <div>
- <a rel="sponsored" target="_blank" href="https://fastapi.tiangolo.com">
- <img src="./sponsor_logos/fastapi.png" alt="FastAPI" />
- <span>FastAPI</span>
- </a>
- </div>
- <div>
- <a rel="sponsored" target="_blank" href="https://aws.amazon.com">
- <img src="./sponsor_logos/aws.png" alt="AWS" />
- <span>AWS</span>
- </a>
- </div>
- <div>
- <a rel="sponsored" target="_blank" href="https://explosion.ai">
- <img src="./sponsor_logos/explosion_ai.png" alt="Explosion" />
- <span>Explosion</span>
- </a>
- </div>
- <div>
- <a rel="sponsored" target="_blank"
href="https://tutorcruncher.com/?utm_source=pydantic&utm_campaign=open_source">
- <img src="./sponsor_logos/tutorcruncher.png" alt="TutorCruncher" />
- <span>TutorCruncher</span>
- </a>
- </div>
- <div>
- <a rel="sponsored" target="_blank"
href="https://www.exoflare.com/open-source/?utm_source=pydantic&utm_campaign=open_source">
- <img src="./sponsor_logos/exoflare.png" alt="ExoFlare" />
- <span>ExoFlare</span>
- </a>
- </div>
- <div>
- <a rel="sponsored" target="_blank" href="https://home.robusta.dev">
- <img src="./sponsor_logos/robusta.png" alt="Robusta" />
- <span>Robusta</span>
- </a>
- </div>
- <div>
- <a rel="sponsored" target="_blank" href="https://www.sendcloud.com">
- <img src="./sponsor_logos/sendcloud.png" alt="SendCloud" />
- <span>SendCloud</span>
- </a>
- </div>
- <div>
- <a rel="sponsored" target="_blank" href="https://jina.ai">
- <img src="./sponsor_logos/jina-ai.png" alt="Jina AI" />
- <span>Jina AI</span>
- </a>
- </div>
-</div>
-
-And many more who kindly sponsor Samuel Colvin on [GitHub
Sponsors](https://github.com/sponsors/samuelcolvin#sponsors).
-
-<script>
- // randomize the order of sponsors
- const ul = document.querySelector('.sponsors')
- for (let i = ul.children.length; i >= 0; i--) {
- ul.appendChild(ul.children[Math.random() * i | 0])
- }
-</script>
-
## Example
{!.tmp_examples/index_main.md!}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/docs/requirements.txt
new/pydantic-1.10.8/docs/requirements.txt
--- old/pydantic-1.10.7/docs/requirements.txt 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/docs/requirements.txt 2023-05-23 19:13:55.000000000
+0200
@@ -12,3 +12,5 @@
sqlalchemy
orjson
ujson
+# waiting for https://github.com/jimporter/mike/issues/154
+git+https://github.com/jimporter/mike.git
Binary files old/pydantic-1.10.7/docs/sponsor_logos/aws.png and
new/pydantic-1.10.8/docs/sponsor_logos/aws.png differ
Binary files old/pydantic-1.10.7/docs/sponsor_logos/exoflare.png and
new/pydantic-1.10.8/docs/sponsor_logos/exoflare.png differ
Binary files old/pydantic-1.10.7/docs/sponsor_logos/explosion_ai.png and
new/pydantic-1.10.8/docs/sponsor_logos/explosion_ai.png differ
Binary files old/pydantic-1.10.7/docs/sponsor_logos/fastapi.png and
new/pydantic-1.10.8/docs/sponsor_logos/fastapi.png differ
Binary files old/pydantic-1.10.7/docs/sponsor_logos/jina-ai.png and
new/pydantic-1.10.8/docs/sponsor_logos/jina-ai.png differ
Binary files old/pydantic-1.10.7/docs/sponsor_logos/robusta.png and
new/pydantic-1.10.8/docs/sponsor_logos/robusta.png differ
Binary files old/pydantic-1.10.7/docs/sponsor_logos/salesforce.png and
new/pydantic-1.10.8/docs/sponsor_logos/salesforce.png differ
Binary files old/pydantic-1.10.7/docs/sponsor_logos/sendcloud.png and
new/pydantic-1.10.8/docs/sponsor_logos/sendcloud.png differ
Binary files old/pydantic-1.10.7/docs/sponsor_logos/tutorcruncher.png and
new/pydantic-1.10.8/docs/sponsor_logos/tutorcruncher.png differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/docs/theme/announce.html
new/pydantic-1.10.8/docs/theme/announce.html
--- old/pydantic-1.10.7/docs/theme/announce.html 1970-01-01
01:00:00.000000000 +0100
+++ new/pydantic-1.10.8/docs/theme/announce.html 2023-05-23
19:13:55.000000000 +0200
@@ -0,0 +1,4 @@
+<!-- the following line is displayed in the announce bar -->
+<!-- keep length under 164 characters (less HTML tags) to fit on 1280px
desktop window -->
+<strong>Pydantic V2 alpha 1 is here:</strong>
+We're releasing the first alpha of Pydantic V2 for evaluation. Read the <a
href="/blog/pydantic-v2-alpha/">alpha release blog post</a> for details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/docs/theme/main.html
new/pydantic-1.10.8/docs/theme/main.html
--- old/pydantic-1.10.7/docs/theme/main.html 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/docs/theme/main.html 2023-05-23 19:13:55.000000000
+0200
@@ -1,13 +1,12 @@
{% extends "base.html" %}
-{% block content %}
- <div class="admonition success announcement">
- <p class="admonition-title">Pydantic Company</p>
- <p>We've started a company based on the principles that I believe have led
to Pydantic's success.</p>
- <p>Learning more from the <a
href="https://pydantic.dev/announcement/">Company Announcement</a>.</p>
- </div>
+<!-- start announce block -->
+{% block announce %}
+ {% include 'announce.html' ignore missing %}
+{% endblock %}
+<!-- end announce block -->
+{% block content %}
{{ super() }}
-
<script src="/flarelytics/client.js"></script>
{% endblock %}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/docs/visual_studio_code.md
new/pydantic-1.10.8/docs/visual_studio_code.md
--- old/pydantic-1.10.7/docs/visual_studio_code.md 2023-03-22
20:29:23.000000000 +0100
+++ new/pydantic-1.10.8/docs/visual_studio_code.md 2023-05-23
19:13:55.000000000 +0200
@@ -192,7 +192,7 @@
The same idea from the previous example can be put on the same line with the
help of `cast()`.
-This way, the type declaration of the value is overriden inline, without
requiring another variable.
+This way, the type declaration of the value is overridden inline, without
requiring another variable.
```Python hl_lines="1 11"
from typing import Any, cast
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/mkdocs.yml
new/pydantic-1.10.8/mkdocs.yml
--- old/pydantic-1.10.7/mkdocs.yml 2023-03-22 20:29:23.000000000 +0100
+++ new/pydantic-1.10.8/mkdocs.yml 2023-05-23 19:13:55.000000000 +0200
@@ -23,6 +23,7 @@
name: "Switch to light mode"
features:
- content.tabs.link
+ - announce.dismiss
logo: 'logo-white.svg'
favicon: 'favicon.png'
@@ -54,6 +55,7 @@
- 'Usage with devtools': usage/devtools.md
- 'Usage with rich': usage/rich.md
- Blog:
+ - blog/pydantic-v2-alpha.md
- blog/pydantic-v2.md
- Contributing to pydantic: contributing.md
- 'Mypy plugin': mypy_plugin.md
@@ -79,7 +81,14 @@
- pymdownx.tabbed:
alternate_style: true
+extra:
+ version:
+ provider: mike
+
plugins:
+- mike:
+ alias_type: symlink
+ canonical_version: latest
- search
- exclude:
glob:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/pydantic/env_settings.py
new/pydantic-1.10.8/pydantic/env_settings.py
--- old/pydantic-1.10.7/pydantic/env_settings.py 2023-03-22
20:29:23.000000000 +0100
+++ new/pydantic-1.10.8/pydantic/env_settings.py 2023-05-23
19:13:55.000000000 +0200
@@ -296,7 +296,7 @@
for env_name in field.field_info.extra['env_names']:
path = find_case_path(secrets_path, env_name,
settings.__config__.case_sensitive)
if not path:
- # path does not exist, we curently don't return a warning
for this
+ # path does not exist, we currently don't return a warning
for this
continue
if path.is_file():
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/pydantic/fields.py
new/pydantic-1.10.8/pydantic/fields.py
--- old/pydantic-1.10.7/pydantic/fields.py 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/pydantic/fields.py 2023-05-23 19:13:55.000000000
+0200
@@ -1107,7 +1107,13 @@
assert self.discriminator_alias is not None
try:
- discriminator_value = v[self.discriminator_alias]
+ try:
+ discriminator_value = v[self.discriminator_alias]
+ except KeyError:
+ if self.model_config.allow_population_by_field_name:
+ discriminator_value = v[self.discriminator_key]
+ else:
+ raise
except KeyError:
return v,
ErrorWrapper(MissingDiscriminator(discriminator_key=self.discriminator_key),
loc)
except TypeError:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/pydantic/mypy.py
new/pydantic-1.10.8/pydantic/mypy.py
--- old/pydantic-1.10.7/pydantic/mypy.py 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/pydantic/mypy.py 2023-05-23 19:13:55.000000000
+0200
@@ -307,15 +307,11 @@
* stores the fields, config, and if the class is settings in the mypy
metadata for access by subclasses
"""
ctx = self._ctx
- info = self._ctx.cls.info
+ info = ctx.cls.info
self.adjust_validator_signatures()
config = self.collect_config()
fields = self.collect_fields(config)
- for field in fields:
- if info[field.name].type is None:
- if not ctx.api.final_iteration:
- ctx.api.defer()
is_settings = any(get_fullname(base) == BASESETTINGS_FULLNAME for base
in info.mro[:-1])
self.add_initializer(fields, config, is_settings)
self.add_construct_method(fields)
@@ -593,7 +589,7 @@
# only required if default is Ellipsis (i.e., `field_name:
Annotation = Field(...)`) or if default_factory
# is specified.
for arg, name in zip(expr.args, expr.arg_names):
- # If name is None, then this arg is the default because it is
the only positonal argument.
+ # If name is None, then this arg is the default because it is
the only positional argument.
if name is None or name == 'default':
return arg.__class__ is EllipsisExpr
if name == 'default_factory':
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/pydantic/networks.py
new/pydantic-1.10.8/pydantic/networks.py
--- old/pydantic-1.10.7/pydantic/networks.py 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/pydantic/networks.py 2023-05-23 19:13:55.000000000
+0200
@@ -706,32 +706,34 @@
def validate_email(value: Union[str]) -> Tuple[str, str]:
"""
- Brutally simple email address validation. Note unlike most email address
validation
+ Email address validation using https://pypi.org/project/email-validator/
+ Notes:
* raw ip address (literal) domain parts are not allowed.
* "John Doe <[email protected]>" style "pretty" email addresses are
processed
- * the local part check is extremely basic. This raises the possibility of
unicode spoofing, but no better
- solution is really possible.
* spaces are striped from the beginning and end of addresses but no error
is raised
-
- See RFC 5322 but treat it with suspicion, there seems to exist no
universally acknowledged test for a valid email!
"""
if email_validator is None:
import_email_validator()
-
m = pretty_email_regex.fullmatch(value)
- name: Optional[str] = None
+ name: Union[str, None] = None
if m:
name, value = m.groups()
-
email = value.strip()
-
try:
- email_validator.validate_email(email, check_deliverability=False)
+ parts = email_validator.validate_email(email,
check_deliverability=False)
except email_validator.EmailNotValidError as e:
- raise errors.EmailError() from e
+ raise errors.EmailError from e
- at_index = email.index('@')
- local_part = email[:at_index] # RFC 5321, local part must be
case-sensitive.
- global_part = email[at_index:].lower()
+ if hasattr(parts, 'normalized'):
+ # email-validator >= 2
+ email = parts.normalized
+ assert email is not None
+ name = name or parts.local_part
+ return name, email
+ else:
+ # email-validator >1, <2
+ at_index = email.index('@')
+ local_part = email[:at_index] # RFC 5321, local part must be
case-sensitive.
+ global_part = email[at_index:].lower()
- return name or local_part, local_part + global_part
+ return name or local_part, local_part + global_part
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/pydantic/schema.py
new/pydantic-1.10.8/pydantic/schema.py
--- old/pydantic-1.10.7/pydantic/schema.py 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/pydantic/schema.py 2023-05-23 19:13:55.000000000
+0200
@@ -369,7 +369,7 @@
def get_flat_models_from_field(field: ModelField, known_models: TypeModelSet)
-> TypeModelSet:
"""
- Take a single Pydantic ``ModelField`` (from a model) that could have been
declared as a sublcass of BaseModel
+ Take a single Pydantic ``ModelField`` (from a model) that could have been
declared as a subclass of BaseModel
(so, it could be a submodel), and generate a set with its model and all
the sub-models in the tree.
I.e. if you pass a field that was declared to be of type ``Foo`` (subclass
of BaseModel) as ``field``, and that
model ``Foo`` has a field of type ``Bar`` (also subclass of ``BaseModel``)
and that model ``Bar`` has a field of
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/pydantic/types.py
new/pydantic-1.10.8/pydantic/types.py
--- old/pydantic-1.10.7/pydantic/types.py 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/pydantic/types.py 2023-05-23 19:13:55.000000000
+0200
@@ -226,7 +226,13 @@
def conint(
- *, strict: bool = False, gt: int = None, ge: int = None, lt: int = None,
le: int = None, multiple_of: int = None
+ *,
+ strict: bool = False,
+ gt: Optional[int] = None,
+ ge: Optional[int] = None,
+ lt: Optional[int] = None,
+ le: Optional[int] = None,
+ multiple_of: Optional[int] = None,
) -> Type[int]:
# use kwargs then define conf in a dict to aid with IDE type hinting
namespace = dict(strict=strict, gt=gt, ge=ge, lt=lt, le=le,
multiple_of=multiple_of)
@@ -369,8 +375,8 @@
strip_whitespace: bool = False,
to_upper: bool = False,
to_lower: bool = False,
- min_length: int = None,
- max_length: int = None,
+ min_length: Optional[int] = None,
+ max_length: Optional[int] = None,
strict: bool = False,
) -> Type[bytes]:
# use kwargs then define conf in a dict to aid with IDE type hinting
@@ -446,10 +452,10 @@
to_upper: bool = False,
to_lower: bool = False,
strict: bool = False,
- min_length: int = None,
- max_length: int = None,
- curtail_length: int = None,
- regex: str = None,
+ min_length: Optional[int] = None,
+ max_length: Optional[int] = None,
+ curtail_length: Optional[int] = None,
+ regex: Optional[str] = None,
) -> Type[str]:
# use kwargs then define conf in a dict to aid with IDE type hinting
namespace = dict(
@@ -510,7 +516,7 @@
return v
-def conset(item_type: Type[T], *, min_items: int = None, max_items: int =
None) -> Type[Set[T]]:
+def conset(item_type: Type[T], *, min_items: Optional[int] = None, max_items:
Optional[int] = None) -> Type[Set[T]]:
# __args__ is needed to conform to typing generics api
namespace = {'min_items': min_items, 'max_items': max_items, 'item_type':
item_type, '__args__': [item_type]}
# We use new_class to be able to deal with Generic types
@@ -552,7 +558,9 @@
return v
-def confrozenset(item_type: Type[T], *, min_items: int = None, max_items: int
= None) -> Type[FrozenSet[T]]:
+def confrozenset(
+ item_type: Type[T], *, min_items: Optional[int] = None, max_items:
Optional[int] = None
+) -> Type[FrozenSet[T]]:
# __args__ is needed to conform to typing generics api
namespace = {'min_items': min_items, 'max_items': max_items, 'item_type':
item_type, '__args__': [item_type]}
# We use new_class to be able to deal with Generic types
@@ -611,7 +619,7 @@
def conlist(
- item_type: Type[T], *, min_items: int = None, max_items: int = None,
unique_items: bool = None
+ item_type: Type[T], *, min_items: Optional[int] = None, max_items:
Optional[int] = None, unique_items: bool = None
) -> Type[List[T]]:
# __args__ is needed to conform to typing generics api
namespace = dict(
@@ -724,8 +732,8 @@
ge: Decimal = None,
lt: Decimal = None,
le: Decimal = None,
- max_digits: int = None,
- decimal_places: int = None,
+ max_digits: Optional[int] = None,
+ decimal_places: Optional[int] = None,
multiple_of: Decimal = None,
) -> Type[Decimal]:
# use kwargs then define conf in a dict to aid with IDE type hinting
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/pydantic/typing.py
new/pydantic-1.10.8/pydantic/typing.py
--- old/pydantic-1.10.7/pydantic/typing.py 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/pydantic/typing.py 2023-05-23 19:13:55.000000000
+0200
@@ -1,4 +1,5 @@
import sys
+import typing
from collections.abc import Callable
from os import PathLike
from typing import ( # type: ignore
@@ -91,6 +92,11 @@
AnnotatedTypeNames = {'AnnotatedMeta', '_AnnotatedAlias'}
+LITERAL_TYPES: Set[Any] = {Literal}
+if hasattr(typing, 'Literal'):
+ LITERAL_TYPES.add(typing.Literal)
+
+
if sys.version_info < (3, 8):
def get_origin(t: Type[Any]) -> Optional[Type[Any]]:
@@ -271,7 +277,13 @@
MappingIntStrAny = Mapping[IntStr, Any]
CallableGenerator = Generator[AnyCallable, None, None]
ReprArgs = Sequence[Tuple[Optional[str], Any]]
- AnyClassMethod = classmethod[Any]
+
+ MYPY = False
+ if MYPY:
+ AnyClassMethod = classmethod[Any]
+ else:
+ # classmethod[TargetType, CallableParamSpecType, CallableReturnType]
+ AnyClassMethod = classmethod[Any, Any, Any]
__all__ = (
'AnyCallable',
@@ -348,10 +360,7 @@
else:
def is_none_type(type_: Any) -> bool:
- for none_type in NONE_TYPES:
- if type_ is none_type:
- return True
- return False
+ return type_ in NONE_TYPES
def display_as_type(v: Type[Any]) -> str:
@@ -409,7 +418,7 @@
def is_literal_type(type_: Type[Any]) -> bool:
- return Literal is not None and get_origin(type_) is Literal
+ return Literal is not None and get_origin(type_) in LITERAL_TYPES
def literal_values(type_: Type[Any]) -> Tuple[Any, ...]:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/pydantic/version.py
new/pydantic-1.10.8/pydantic/version.py
--- old/pydantic-1.10.7/pydantic/version.py 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/pydantic/version.py 2023-05-23 19:13:55.000000000
+0200
@@ -1,6 +1,6 @@
__all__ = 'compiled', 'VERSION', 'version_info'
-VERSION = '1.10.7'
+VERSION = '1.10.8'
try:
import cython # type: ignore
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/requirements.txt
new/pydantic-1.10.8/requirements.txt
--- old/pydantic-1.10.7/requirements.txt 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/requirements.txt 2023-05-23 19:13:55.000000000
+0200
@@ -2,7 +2,7 @@
Cython==0.29.32;sys_platform!='win32'
devtools==0.9.0
-email-validator==1.2.1
+email-validator==2.0.0.post2
dataclasses==0.6; python_version < '3.7'
typing-extensions==4.3.0
python-dotenv==0.20.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/tests/mypy/modules/plugin_success.py
new/pydantic-1.10.8/tests/mypy/modules/plugin_success.py
--- old/pydantic-1.10.7/tests/mypy/modules/plugin_success.py 2023-03-22
20:29:23.000000000 +0100
+++ new/pydantic-1.10.8/tests/mypy/modules/plugin_success.py 2023-05-23
19:13:55.000000000 +0200
@@ -262,3 +262,19 @@
Sample(foo='hello world')
+
+
+def get_my_custom_validator(field_name: str) -> Any:
+ @validator(field_name, allow_reuse=True)
+ def my_custom_validator(cls: Any, v: int) -> int:
+ return v
+
+ return my_custom_validator
+
+
+def foo() -> None:
+ class MyModel(BaseModel):
+ number: int
+ custom_validator = get_my_custom_validator('number')
+
+ MyModel(number=2)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pydantic-1.10.7/tests/mypy/outputs/plugin-success-strict.txt
new/pydantic-1.10.8/tests/mypy/outputs/plugin-success-strict.txt
--- old/pydantic-1.10.7/tests/mypy/outputs/plugin-success-strict.txt
2023-03-22 20:29:23.000000000 +0100
+++ new/pydantic-1.10.8/tests/mypy/outputs/plugin-success-strict.txt
2023-05-23 19:13:55.000000000 +0200
@@ -1,3 +1,4 @@
30: error: Unexpected keyword argument "z" for "Model" [call-arg]
65: error: Untyped fields disallowed [pydantic-field]
80: error: Argument "x" to "OverrideModel" has incompatible type "float";
expected "int" [arg-type]
+278: error: Untyped fields disallowed [pydantic-field]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/tests/mypy/test_mypy.py
new/pydantic-1.10.8/tests/mypy/test_mypy.py
--- old/pydantic-1.10.7/tests/mypy/test_mypy.py 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/tests/mypy/test_mypy.py 2023-05-23 19:13:55.000000000
+0200
@@ -64,7 +64,15 @@
# Specifying a different cache dir for each configuration dramatically
speeds up subsequent execution
# It also prevents cache-invalidation-related bugs in the tests
cache_dir = f'.mypy_cache/test-{os.path.splitext(config_filename)[0]}'
- command = [full_filename, '--config-file', full_config_filename,
'--cache-dir', cache_dir, '--show-error-codes']
+ command = [
+ full_filename,
+ '--config-file',
+ full_config_filename,
+ '--cache-dir',
+ cache_dir,
+ '--show-error-codes',
+ '--show-traceback',
+ ]
print(f"\nExecuting: mypy {' '.join(command)}") # makes it easier to
debug as necessary
actual_result = mypy_api.run(command)
actual_out, actual_err, actual_returncode = actual_result
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/tests/requirements-testing.txt
new/pydantic-1.10.8/tests/requirements-testing.txt
--- old/pydantic-1.10.7/tests/requirements-testing.txt 2023-03-22
20:29:23.000000000 +0100
+++ new/pydantic-1.10.8/tests/requirements-testing.txt 2023-05-23
19:13:55.000000000 +0200
@@ -1,11 +1,14 @@
coverage==6.4.4
hypothesis==6.54.4
# pin importlib-metadata as upper versions need typing-extensions to work if
on Python < 3.8
-importlib-metadata==3.1.0;python_version<"3.8"
+importlib-metadata==3.6.0;python_version<"3.8"
mypy==0.971
pytest==7.2.1
pytest-cov==4.0.0
pytest-mock==3.10.0
pytest-sugar==0.9.6
# pin typing-extensions to minimum requirement - see #4885
-typing-extensions==4.2.0
+typing-extensions==4.6.0
+# used in FastAPI tests, pin to avoid warnings in newer version
+# that FastAPI needs to fix
+Flask==2.2.3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/tests/test_discrimated_union.py
new/pydantic-1.10.8/tests/test_discrimated_union.py
--- old/pydantic-1.10.7/tests/test_discrimated_union.py 2023-03-22
20:29:23.000000000 +0100
+++ new/pydantic-1.10.8/tests/test_discrimated_union.py 2023-05-23
19:13:55.000000000 +0200
@@ -285,6 +285,80 @@
assert Top(sub=B(literal='b')).sub.literal == 'b'
+def test_discriminated_union_model_with_alias():
+ class A(BaseModel):
+ literal: Literal['a'] = Field(alias='lit')
+
+ class B(BaseModel):
+ literal: Literal['b'] = Field(alias='lit')
+
+ class Config:
+ allow_population_by_field_name = True
+
+ class TopDisallow(BaseModel):
+ sub: Union[A, B] = Field(..., discriminator='literal', alias='s')
+
+ class TopAllow(BaseModel):
+ sub: Union[A, B] = Field(..., discriminator='literal', alias='s')
+
+ class Config:
+ allow_population_by_field_name = True
+
+ assert TopDisallow.parse_obj({'s': {'lit': 'a'}}).sub.literal == 'a'
+
+ with pytest.raises(ValidationError) as exc_info:
+ TopDisallow.parse_obj({'s': {'literal': 'b'}})
+
+ assert exc_info.value.errors() == [
+ {
+ 'ctx': {'discriminator_key': 'literal'},
+ 'loc': ('s',),
+ 'msg': "Discriminator 'literal' is missing in value",
+ 'type': 'value_error.discriminated_union.missing_discriminator',
+ },
+ ]
+
+ with pytest.raises(ValidationError) as exc_info:
+ TopDisallow.parse_obj({'s': {'literal': 'a'}})
+
+ assert exc_info.value.errors() == [
+ {
+ 'ctx': {'discriminator_key': 'literal'},
+ 'loc': ('s',),
+ 'msg': "Discriminator 'literal' is missing in value",
+ 'type': 'value_error.discriminated_union.missing_discriminator',
+ }
+ ]
+
+ with pytest.raises(ValidationError) as exc_info:
+ TopDisallow.parse_obj({'sub': {'lit': 'a'}})
+
+ assert exc_info.value.errors() == [
+ {'loc': ('s',), 'msg': 'field required', 'type':
'value_error.missing'},
+ ]
+
+ assert TopAllow.parse_obj({'s': {'lit': 'a'}}).sub.literal == 'a'
+ assert TopAllow.parse_obj({'s': {'lit': 'b'}}).sub.literal == 'b'
+ assert TopAllow.parse_obj({'s': {'literal': 'b'}}).sub.literal == 'b'
+ assert TopAllow.parse_obj({'sub': {'lit': 'a'}}).sub.literal == 'a'
+ assert TopAllow.parse_obj({'sub': {'lit': 'b'}}).sub.literal == 'b'
+ assert TopAllow.parse_obj({'sub': {'literal': 'b'}}).sub.literal == 'b'
+
+ with pytest.raises(ValidationError) as exc_info:
+ TopAllow.parse_obj({'s': {'literal': 'a'}})
+
+ assert exc_info.value.errors() == [
+ {'loc': ('s', 'A', 'lit'), 'msg': 'field required', 'type':
'value_error.missing'},
+ ]
+
+ with pytest.raises(ValidationError) as exc_info:
+ TopAllow.parse_obj({'sub': {'literal': 'a'}})
+
+ assert exc_info.value.errors() == [
+ {'loc': ('s', 'A', 'lit'), 'msg': 'field required', 'type':
'value_error.missing'},
+ ]
+
+
def test_discriminated_union_int():
class A(BaseModel):
l: Literal[1]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/tests/test_types.py
new/pydantic-1.10.8/tests/test_types.py
--- old/pydantic-1.10.7/tests/test_types.py 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/tests/test_types.py 2023-05-23 19:13:55.000000000
+0200
@@ -3440,3 +3440,22 @@
'type': 'value_error.date.not_in_the_future',
}
]
+
+
+def test_typing_extension_literal_field():
+ from typing_extensions import Literal
+
+ class Model(BaseModel):
+ foo: Literal['foo']
+
+ assert Model(foo='foo').foo == 'foo'
+
+
[email protected](sys.version_info < (3, 8), reason='`typing.Literal` is
available for python 3.8 and above.')
+def test_typing_literal_field():
+ from typing import Literal
+
+ class Model(BaseModel):
+ foo: Literal['foo']
+
+ assert Model(foo='foo').foo == 'foo'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/tests/test_typing.py
new/pydantic-1.10.8/tests/test_typing.py
--- old/pydantic-1.10.7/tests/test_typing.py 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/tests/test_typing.py 2023-05-23 19:13:55.000000000
+0200
@@ -6,7 +6,7 @@
from typing_extensions import Annotated # noqa: F401
from pydantic import Field # noqa: F401
-from pydantic.typing import Literal, convert_generics, is_namedtuple,
is_none_type, is_typeddict
+from pydantic.typing import Literal, convert_generics, is_literal_type,
is_namedtuple, is_none_type, is_typeddict
try:
from typing import TypedDict as typing_TypedDict
@@ -124,3 +124,18 @@
assert (
convert_generics(dict['Hero', list['Team']] | int) ==
dict[ForwardRef('Hero'), list[ForwardRef('Team')]] | int
)
+
+
+def test_is_literal_with_typing_extension_literal():
+ from typing_extensions import Literal
+
+ assert is_literal_type(Literal) is False
+ assert is_literal_type(Literal['foo']) is True
+
+
[email protected](sys.version_info < (3, 8), reason='`typing.Literal` is
available for python 3.8 and above.')
+def test_is_literal_with_typing_literal():
+ from typing import Literal
+
+ assert is_literal_type(Literal) is False
+ assert is_literal_type(Literal['foo']) is True
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pydantic-1.10.7/tests/test_utils.py
new/pydantic-1.10.8/tests/test_utils.py
--- old/pydantic-1.10.7/tests/test_utils.py 2023-03-22 20:29:23.000000000
+0100
+++ new/pydantic-1.10.8/tests/test_utils.py 2023-05-23 19:13:55.000000000
+0200
@@ -8,10 +8,9 @@
from typing import Callable, Dict, ForwardRef, List, NewType, Tuple, TypeVar,
Union
import pytest
-from pkg_resources import safe_version
from typing_extensions import Annotated, Literal
-from pydantic import VERSION, BaseModel, ConstrainedList, conlist
+from pydantic import BaseModel, ConstrainedList, conlist
from pydantic.color import Color
from pydantic.dataclasses import dataclass
from pydantic.fields import Undefined
@@ -377,10 +376,6 @@
assert s.count('\n') == 5
-def test_standard_version():
- assert safe_version(VERSION) == VERSION
-
-
def test_class_attribute():
class Foo:
attr = ClassAttribute('attr', 'foo')