1
0

- drop optional email-validator dependency

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pydantic?expand=0&rev=57
This commit is contained in:
2024-06-30 20:45:03 +00:00
committed by Git OBS Bridge
commit fd0f827663
7 changed files with 1166 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.osc

3
_multibuild Normal file
View File

@@ -0,0 +1,3 @@
<multibuild>
<package>test</package>
</multibuild>

3
pydantic-2.7.4.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a5fc6c585a6af719d2759719a0eaf01419378fb947e76d170afba6e465ed598f
size 2749073

661
python-pydantic.changes Normal file
View File

@@ -0,0 +1,661 @@
-------------------------------------------------------------------
Sun Jun 30 20:44:51 UTC 2024 - Dirk Müller <dmueller@suse.com>
- drop optional email-validator dependency
-------------------------------------------------------------------
Mon Jun 24 15:45:05 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 2.7.4:
* Bump `pydantic.v1` to `v1.10.16` reference
* Specify `recursive_guard` as kwarg in `FutureRef._evaluate`
-------------------------------------------------------------------
Thu Jun 6 14:14:46 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 2.7.3:
* Bump `pydantic-core` to `v2.18.4`
* Fix u style unicode strings in python @samuelcolvin in
pydantic/jiter#110
* Replace `__spec__.parent` with `__package__`
* Fix validation of `int`s with leading unary minus
* Fix `str` subclass validation for enums
* Support `BigInt`s in `Literal`s and `Enum`s
* Fix: uuid - allow `str` subclass as input
-------------------------------------------------------------------
Thu May 30 04:56:19 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch support-pytest-8.patch:
* Support changes in pytest 8.x.
-------------------------------------------------------------------
Sat Apr 27 07:45:31 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 2.7.1:
* Bump `pydantic-core` to `v2.18.2`
* Ftp and Websocket connection strings support
* Use field description for RootModel schema description when
there is `…`
* Fix `validation_alias` behavior with `model_construct` for
`AliasChoices` and `AliasPath`
* Revert `typing.Literal` and import it outside the
TYPE_CHECKING block
* Fix `Secret` serialization schema, applicable for unions
* Fix `strict` application to `function-after` with
`use_enum_values`
* Address case where `model_construct` on a class which defines
`model_post_init` fails with `AttributeError`
* Fix `model_json_schema` with config types
* Support multiple zeros as an `int`
* Fix validation of `int`s with leading unary plus
* Fix interaction between `extra != 'ignore'` and
`from_attributes=True`
* Handle error from `Enum`'s `missing` function as
`ValidationError`
* Fix memory leak with `Iterable` validation
* Adopt `jiter` `v0.2.0`
* Extract attribute docstrings from `FieldInfo.description`
* Add a `with_config` decorator to comply with typing spec
* Allow an optional separator splitting the value and unit of
the result of `ByteSize.human_readable`
* Add generic `Secret` base type
* Make use of `Sphinx` inventories for cross references in docs
* Add environment variable to disable plugins
* Add support for `deprecated` fields
* Allow `field_serializer('*')`
* Handle a case when `model_config` is defined as a model
property
* Update `create_model()` to support `typing.Annotated` as
input
* Add `ClickhouseDsn` support
* Add support for `re.Pattern[str]` to `pattern` field
* Support for `serialize_as_any` runtime setting
* Add support for `typing.Self`
* Ability to pass `context` to serialization
* Add feedback widget to docs with flarelytics integration
* Support for parsing partial JSON strings in Python
* Add support for field level number to str coercion option
* Update `warnings` parameter for serialization utilities to
allow raising a warning
-------------------------------------------------------------------
Sat Mar 16 11:56:01 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 2.6.4:
* Fix usage of `AliasGenerator` with `computed_field` decorator
* Fix nested discriminated union schema gen, pt 2
* Fix bug with no_strict_optional=True caused by API deferral
-------------------------------------------------------------------
Thu Mar 7 03:28:00 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Update to 2.6.3 (bsc#1222806, CVE-2024-3772):
* Fix inheriting `Field` annotations in dataclasses
* Fix warning for tuple of wrong size in `Union`
* Fix `computed_field` JSON serializer `exclude_none` behavior
* Check for `email-validator` version >= 2.0
* Add `NatsDsn`
* Add `ConfigDict.ser_json_inf_nan`
* Support `AliasGenerator` usage
* Support `yyyy-MM-DD` datetime parsing
* Added bits conversions to the `ByteSize` class
* Add `eval_type_backport` to handle union operator
* Add support for `dataclass` fields `init`
* Implement pickling for `ValidationError`
* Add unified tuple validator that can handle "variadic" tuples via PEP-646
* Drop Python3.7 support
* Make `@validate_call` return a function instead of a custom descriptor
* Introducing `classproperty` decorator for `model_computed_fields`
* Move `getattr` warning in deprecated `BaseConfig`
* Only hash `model_fields`, not whole `__dict__`
* Fix overload position of `computed_field`
* Fix issue `unittest.mock` deprecation warnings
* Fix `to_snake` conversion
* Add support for field `alias` in `dataclass` signature
* Fix ordering of keys in `__dict__` with `model_construct` call
* Fix usage of `@deprecated`
* Add more support for private attributes in `model_construct` call
* Support `pydantic.Field(repr=False)` in dataclasses
* Override `dataclass_transform` behavior for `RootModel`
* Refactor signature generation for simplicity
* Fix ordering bug of PlainValidator annotation
* Fix `exclude_none` for json serialization of `computed_field`s
* Support yyyy-MM-DD string for datetimes
* Fix memory leak with recursive definitions creating reference cycles
* Add `ConfigDict.ser_json_inf_nan`
* Fix validation of `Literal` from JSON keys when used as `dict` key
* Fix bug re `custom_init` on members of `Union`
* Fix `JsonValue` `bool` serialization
* Fix handling of unhashable inputs with `Literal` in `Union`s
Fix package description limit
* Allow plugins to catch non `ValidationError` errors
* Added `validation_error_cause` to config
* Allow `str` as argument to `Discriminator`
* Add `SchemaSerializer.__reduce__` method to enable pickle serialization
* Properly rebuild the `FieldInfo` when a forward ref gets evaluated
* Fix failure to load `SecretStr` from JSON (regression in v2.4)
* Fix `defer_build` behavior with `TypeAdapter`
* Fix: update `TypeVar` handling when default is not set
* Raise an error when deleting frozen (model) fields
* Use generated alias for aliases that are not specified otherwise
* Fix: support `pydantic.Field(kw_only=True)` with inherited dataclasses
* Support `validate_call` decorator for methods in classes with `__slots__`
* Fix pydantic dataclass problem with `dataclasses.field` default
* Support `|` operator (Union) in PydanticRecursiveRef
* Add support for `NotRequired` generics in `TypedDict`
* Added fix for signature of inherited dataclass
* `PrivateAttr` is passed from `Annotated` default position
* Don't decode bytes (which may not be UTF8) when displaying SecretBytes
* Use `classmethod` instead of `classmethod[Any, Any, Any]`
* Clearer error on invalid Plugin
* Correct pydantic dataclasses import
* Fix `definition-ref` bug with `Dict` keys
* Don't accept `NaN` in float and decimal constraints
* Add `lax_str` and `lax_int` support for enum values not inherited
from str/int
* Fix: proper pluralization in `ValidationError` messages
* Disallow the string `'-'` as `datetime` input
* Fix: NaN and Inf float serialization
* Implement optional `number` to `str` coercion
* Add `BaseModel.model_validate_strings` and `TypeAdapter.validate_strings`
* Add Pydantic `plugins` experimental implementation
* Do not override `model_post_init` in subclass with private attrs
* Fix config detection for `TypedDict` from grandparent classes
* Fix hash function generation for frozen models with unusual MRO
* Make `strict` config overridable in field for Path
* Use `ser_json_<timedelta|bytes>` on default in `GenerateJsonSchema`
* Adding a check that alias is validated as an identifier for Python
* Raise an error when computed field overrides field
* Enforce behavior of private attributes having double leading underscore
* Fix generic dataclass fields mutation bug (when using `TypeAdapter`)
* Fix `TypeError` on `model_validator` in `wrap` mode
* Fixed a regular expression denial of service issue by limiting whitespaces
* Fix handling of `UUID` values having `UUID.version=None`
* Fix `__iter__` returning private `cached_property` info
* Make ModelWrapValidator protocols generic
* Make shadowing attributes a warning instead of an error
* Document `Base64Str` and `Base64Bytes`
* Fix `config.defer_build` for serialization first cases
* Support `__get_validators__`
* Replace MiMalloc w/ default allocator
* Cleaner error for invalid input to `Path` fields
* Add section about Constrained classes to the Migration Guide
* Fix issue where generic models couldn't be parametrized with BaseModel
* add field_serializer to computed_field
* fix dataclass annotated before validator called twice
* Add benchmark representing FastAPI startup time
* Fix json_encoders for Enum subclasses
* Revert "Fix default port for mongosrv DSNs (#6827)"
* Do not require `validate_assignment` to use `Field.frozen`
* Fix generic computed fields
* Handle non-json native enum values
* Include Field extra keys name in warning
* Skip FieldInfo merging when unnecessary
* Add `StringConstraints` for use as Annotated metadata
* Fix incorrect subclass check for secretstr
* Mypy plugin for settings
* fast-path checking finite decimals
* Fix pydantic dataclasses that use slots with default values
* Fix inheritance of hash function for frozen models
* Error if an invalid field name is used with Field
* Add `GenericModel` to `MOVED_IN_V2`
* remove email validation from the north star benchmark
* Fix default port for mongosrv DSNs
* Fix serialization issue with `InstanceOf`
* Add back support for `json_encoders`
* Use `WeakValueDictionary` to fix generic memory leak
* Add `config.defer_build` to optionally make model building lazy
* Revise the section on required / optional / nullable fields.
* Replace TransformSchema with GetPydanticSchema
* Fix serialization for IPvAny
* Touch up Decimal validator
* Handle function validators in a discriminated union
* Fix pydantic dataclass problem with dataclasses.field default_factory
* Produce more accurate signatures for pydantic dataclasses
* Ignore unrecognized fields from dataclasses metadata
- Drop patches Fix-Python-3.12-test-failures.patch and
ignore-urllib3-pyopenssl-warning.patch
- Switch to pyproject macros.
- Inject mulitbuild.
-------------------------------------------------------------------
Mon Jan 22 09:12:28 UTC 2024 - Dirk Müller <dmueller@suse.com>
- update to 1.10.14:
* Update install.md
* Fixes ci to only deploy docs on release
* Fix cached_property handling in dataclasses when copied
-------------------------------------------------------------------
Thu Nov 16 09:58:50 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to 1.10.13:
* Fix: Add max length check to `pydantic.validate_email`
* Docs: Fix pip commands to install v1
* Fixes the `maxlen` property being dropped on `deque`
validation. Happened only if the deque item has been typed.
Changes the `_validate_sequence_like` func, #6581 by
* Importing create_model in tools.py through relative path
instead of absolute path - so that it doesn't import V2 code
when copied over to V2 branch, #6361 by @SharathHuddar
* Add Pydantic `Json` field support to settings management,
* Fixed literal validator errors for unhashable values
* Fixed bug with generics receiving forward refs
* Update install method of FastAPI for internal tests in CI,
#6117 by @Kludex
- add Fix-Python-3.12-test-failures.patch: fix test fails with
Python 3.12
-------------------------------------------------------------------
Wed Jul 5 13:07:17 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to 1.10.9:
* Fix trailing zeros not ignored in Decimal validation
* Fix mypy plugin for v1.4.0
* Add future and past date hypothesis strategies
* Discourage usage of Cython 3 with Pydantic 1.x
-------------------------------------------------------------------
Thu May 25 07:32:32 UTC 2023 - Daniel Garcia <daniel.garcia@suse.com>
- 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
-------------------------------------------------------------------
Mon Mar 27 10:00:20 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to 1.10.7:
* Fix creating schema from model using `ConstrainedStr` with
`regex` as dict key
* Address bug in mypy plugin caused by
explicit_package_bases=True
* Add implicit defaults in the mypy plugin for Field with no
default argument
* Fix schema generated for Enum values used as Literals in
discriminated unions
* Fix mypy failures caused by the pydantic mypy plugin when
users define `from_orm` in their own classes
* Fix `InitVar` usage with pydantic dataclasses, mypy version
`1.1.1` and the custom mypy plugin
* Implement logic to support creating validators from non
standard callables by using defaults to identify them and
unwrapping `functools.partial` and `functools.partialmethod`
when checking the signature
* Fix mypy plugin for v1.1.1, and fix `dataclass_transform`
decorator for pydantic dataclasses
* Raise `ValidationError`, not `ConfigError`, when a
discriminator value is unhashable
* Fix broken parametrized bases handling with `GenericModel`s
with complex sets of models
* Invalidate mypy cache if plugin config changes
* Fix `RecursionError` when deep-copying dataclass types
wrapped by pydantic
* Fix `X | Y` union syntax breaking `GenericModel`
-------------------------------------------------------------------
Thu Mar 16 07:18:03 UTC 2023 - Daniel Garcia <daniel.garcia@suse.com>
- Disable DeprecationWarning in tests to avoid error with the latest
setuptools and pkg_resources deprecation
-------------------------------------------------------------------
Mon Jan 2 20:22:05 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to v1.10.4:
* Change dependency to typing-extensions>=4.2.0, #4885 by @samuelcolvin
* fix parsing of custom root models, #4883 by @gou177
* fix: use dataclass proxy for frozen or empty dataclasses, #4878 by
@PrettyWood
* Fix schema and schema_json on models where a model instance is a one of
default values, #4781 by @Bobronium
* Add Jina AI to sponsors on docs index page, #4767 by @samuelcolvin
* fix: support assignment on DataclassProxy, #4695 by @PrettyWood
* Add postgresql+psycopg as allowed scheme for PostgreDsn to make it
usable with SQLAlchemy 2, #4689 by @morian
* Allow dict schemas to have both patternProperties and
additionalProperties, #4641 by @jparise
* Fixes error passing None for optional lists with unique_items, #4568 by
@mfulgo
* Fix GenericModel with Callable param raising a TypeError, #4551 by
@mfulgo
* Fix field regex with StrictStr type annotation, #4538 by @sisp
* Correct dataclass_transform keyword argument name from field_descriptors
to field_specifiers, #4500 by @samuelcolvin
* fix: avoid multiple calls of __post_init__ when dataclasses are
inherited, #4487 by @PrettyWood
* Reduce the size of binary wheels, #2276 by @samuelcolvin
-------------------------------------------------------------------
Fri Sep 9 00:47:25 UTC 2022 - Steve Kowalik <steven.kowalik@suse.com>
- Update to 1.10.2:
* Prevent long (length > 4_300) strings/bytes as input to int fields, see
python/cpython#95778 and CVE-2020-10735
* fix: dataclass wrapper was not always called
* Use tomllib on Python 3.11 when parsing mypy configuration
* Basic fix of GenericModel cache to detect order of arguments in Union models
* Fix mypy plugin when using bare types like list and dict as default_factory
* Add __hash__ method to pydancic.color.Color class
* Refactor the whole pydantic dataclass decorator to really act like its
standard lib equivalent. It hence keeps __eq__, __hash__, ... and makes
comparison with its non-validated version possible.
* Now that Config.extra is supported, dataclass ignores by default extra
arguments (like BaseModel)
* Fix PEP487 __set_name__ protocol in BaseModel for PrivateAttrs
* Allow for custom parsing of environment variables via parse_env_var in
Config
* Fix StrictStr does not raise ValidationError when max_length is present
in Field
* Make SecretStr and SecretBytes hashable
* Fix StrictBytes does not raise ValidationError when max_length is present
in Field
* Add support for bare type
* Support Python 3.11, including binaries for 3.11 in PyPI
* Add support for re.Pattern
* Fix __post_init_post_parse__ is incorrectly passed keyword arguments when
no __post_init__ is defined
* Fix implicitly importing ForwardRef and Callable from pydantic.typing
instead of typing and also expose MappingIntStrAny
* remove Any types from the dataclass decorator so it can be used with the
disallow_any_expr mypy option
* fix "extra fields not permitted" error when dataclass with Extra.forbid
is validated multiple times
* Discriminated union models now use oneOf instead of anyOf when generating
OpenAPI schema definitions
* Allow type checkers to infer inner type of Json type. Json[list[str]] will
be now inferred as list[str]
* Allow empty string aliases by using a alias is not None check, rather
than bool(alias)
* Use parent model's Config when validating nested NamedTuple fields
* Update BaseModel.construct to work with aliased Fields
* Catch certain raised errors in smart_deepcopy and revert to deepcopy if so
* Add Config.anystr_upper and to_upper kwarg to constr and conbytes
* Fix JSON schema for set and frozenset when they include default values
* Teach the mypy plugin that methods decorated by @validator are classmethods
* Improve mypy plugin's ability to detect required fields
* Support fields of type Type[] in schema
* Adds reserved word check to signature generation logic
* Fix Json strategy failure for the complex nested field
* Add JSON-compatible float constraint allow_inf_nan
* Remove undefined behaviour when env_prefix had characters in common with
env_nested_delimiter
* Support generics model with create_model
* allow submodels to overwrite extra field info
* support overwriting dunder attributes of BaseModel instances
* Support kw_only in dataclasses
* Add comparison method for Color class
* created new function to_lower_camel() for "non pascal case" camel case
* Add checks to default and default_factory arguments in Mypy plugin
* Fix parsing of very small numeric timedelta values
* Update SecretsSettingsSource to respect config.case_sensitive
* Add support for multiple dotenv files
* Raise an explicit ConfigError when multiple fields are incorrectly set
for a single validator
* Allow ellipsis on Fields inside Annotated for TypedDicts required
* Catch overflow errors in int_validator
* validate_arguments decorator now supports alias
* Add ability to use Final in a field type annotation
* Update requirement to typing_extensions>=4.1.0 to guarantee
dataclass_transform is available
- Remove patch remove-pkg_resources.patch:
* Included upstream.
- Add patch ignore-urllib3-pyopenssl-warning.patch:
* Ignore DeprecationWarning until requests-toolbelt is fixed.
- Update {Build,}Requires to email-validator package.
-------------------------------------------------------------------
Tue Jul 19 09:20:43 UTC 2022 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch remove-pkg_resources.patch:
* Use packaging, not pkg_resources for versions.
-------------------------------------------------------------------
Sat Jun 18 13:37:28 UTC 2022 - Michael Ströder <michael@stroeder.com>
- Update to 1.9.1
* Limit the size of generics._generic_types_cache and generics._assigned_parameters
to avoid unlimited increase in memory usage, #4083 by @samuelcolvin
* Add Jupyverse and FPS as Jupyter projects using pydantic, #4082 by @davidbrochart
* Speedup __isinstancecheck__ on pydantic models when the type is not a model,
may also avoid memory "leaks", #4081 by @samuelcolvin
* Fix in-place modification of FieldInfo that caused problems with
PEP 593 type aliases, #4067 by @adriangb
* Add support for autocomplete in VS Code via __dataclass_transform__
when using pydantic.dataclasses.dataclass, #4006 by @giuliano-oliveira
* Remove benchmarks from codebase and docs, #3973 by @samuelcolvin
* Typing checking with pyright in CI, improve docs on vscode/pylance/pyright, #3972 by @samuelcolvin
* Fix nested Python dataclass schema regression, #3819 by @himbeles
* Update documentation about lazy evaluation of sources for Settings, #3806 by @garyd203
* Prevent subclasses of bytes being converted to bytes, #3706 by @samuelcolvin
* Fixed "error checking inheritance of" when using PEP585 and PEP604 type hints, #3681 by @aleksul
* Allow self referencing ClassVars in models, #3679 by @samuelcolvin
* Fix issue with self-referencing dataclass, #3675 by @uriyyo
* Include non-standard port numbers in rendered URLs, #3652 by @dolfinus
* Config.copy_on_model_validation does a deep copy and not a shallow one, #3641 by @PrettyWood
* fix: clarify that discriminated unions do not support singletons, #3636 by @tommilligan
* Add read_text(encoding='utf-8') for setup.py, #3625 by @hswong3i
* Fix JSON Schema generation for Discriminated Unions within lists, #3608 by @samuelcolvin
-------------------------------------------------------------------
Wed Feb 2 04:12:37 UTC 2022 - Steve Kowalik <steven.kowalik@suse.com>
- Skip some truculent tests.
- Clean up non-required Python 3.6 {Build,}Requires.
-------------------------------------------------------------------
Wed Jan 5 16:08:23 UTC 2022 - Ben Greiner <code@bnavigator.de>
- Update to 1.9.0
* add python 3.10 support, #2885 by @PrettyWood
* Discriminated unions, #619 by @PrettyWood
* Config.smart_union for better union logic, #2092 by @PrettyWood
* Binaries for Macos M1 CPUs, #3498 by @samuelcolvin
* Complex types can be set via nested environment variables, e.g.
foo___bar, #3159 by @Air-Mark
* add a dark mode to pydantic documentation, #2913 by @gbdlin
* Add support for autocomplete in VS Code via
__dataclass_transform__, #2721 by @tiangolo
* Add "exclude" as a field parameter so that it can be configured
using model config, #660 by @daviskirk
- Full changelog in HISTORY.md
-------------------------------------------------------------------
Thu May 13 11:07:30 UTC 2021 - Markéta Machová <mmachova@suse.com>
- Update to 1.8.2 (bsc#1186019, CVE-2021-29510)
* Security fix: Fix date and datetime parsing so passing either 'infinity'
or float('inf') (or their negative values) does not cause an infinite loop
* Allow passing json_encoders in class kwargs
* support arbitrary types with custom __eq__
* Hypothesis plugin for testing
* support for NamedTuple and TypedDict
* Support Annotated hints on model fields
* frozen parameter on Config to allow models to be hashed
* Breaking Change, remove old deprecation aliases from v1
* Breaking Change: always validate only first sublevel items with each_item
* many more changes, see upstream changelog
-------------------------------------------------------------------
Fri Jan 8 13:10:40 UTC 2021 - Markéta Machová <mmachova@suse.com>
- Update to 1.7.3
* python 3.9 support
* Private model attributes
* "secrets files" support in BaseSettings
* convert stdlib dataclasses to pydantic dataclasses and use stdlib dataclasses in models
* few bugfixes
- Drop validate-config.patch
-------------------------------------------------------------------
Mon Dec 7 01:00:22 UTC 2020 - Benjamin Greiner <code@bnavigator.de>
- Add dataclasses requirement for Python 3.6: Fixes Leap 15.2 build
and future TW python36 flavor gh#openSUSE/python-rpm-macros#66
-------------------------------------------------------------------
Mon Oct 12 08:58:44 UTC 2020 - Marketa Calabkova <mcalabkova@suse.com>
- Add upstream patch validate-config.patch which fixes build with new pytest
-------------------------------------------------------------------
Sun Aug 2 15:14:47 UTC 2020 - John Vandenberg <jayvdb@gmail.com>
- Add optional test dependencies
- Recommend optional runtime dependency python-typing_extensions
- Remove unused runtime dependency ujson
- Update to v1.6.1
* fix validation and parsing of nested models with default_factory
- from v1.6
* Modify validators for conlist and conset to not have always=True
* Add port check to AnyUrl (can't exceed 65536) ports are 16 insigned
bits: 0 <= port <= 2**16-1 src: rfc793 header format
* Document default regex anchoring semantics
* Use chain.from_iterable in class_validators.py. This is a faster
and more idiomatic way of using itertools.chain. Instead of computing
all the items in the iterable and storing them in memory, they are
computed one-by-one and never stored as a huge list.
This can save on both runtime and memory space
* Add conset(), analogous to conlist()
* make pydantic errors (un)pickable
* Allow custom encoding for dotenv files
* Ensure SchemaExtraCallable is always defined to get type hints on BaseConfig
* Update datetime parser to support negative timestamps
* Update mypy, remove AnyType alias for Type[Any]
* Adjust handling of root validators so that errors are aggregated
from all failing root validators, instead of reporting on only
the first root validator to fail
* Make __modify_schema__ on Enums apply to the enum schema rather
than fields that use the enum
* Fix behavior of __all__ key when used in conjunction with index
keys in advanced include/exclude of fields that are sequences
* Subclass validators do not run when referencing a List field
defined in a parent class when each_item=True
* change schema.field_class_to_schema to support frozenset in schema
* Call __modify_schema__ only for the field schema
* Move the assignment of field.validate_always in fields.py so the
always parameter of validators work on inheritance
* Added support for UUID instantiation through 16 byte strings such
as b'\x12\x34\x56\x78' * 4.
This was done to support BINARY(16) columns in sqlalchemy
* Add a test assertion that default_factory can return a singleton
* Add NameEmail.__eq__ so duplicate NameEmail instances are
evaluated as equal
* Add datamodel-code-generator link in pydantic document site
* Added a "Discussion of Pydantic" section to the documentation,
with a link to "Pydantic Introduction" video
* Avoid some side effects of default_factory by calling it only
once if possible and by not setting a default value in the schema
* Added docs about dumping dataclasses to JSON
* Make BaseModel.__signature__ class-only, so getting __signature__
from model instance will raise AttributeError
* include 'format': 'password' in the schema for secret types
* Modify schema constraints on ConstrainedFloat so that
exclusiveMinimum and minimum are not included in the schema if
they are equal to -math.inf and exclusiveMaximum and maximum are
not included if they are equal to math.inf
* Squash internal __root__ dicts in .dict() (and, by extension, in .json())
* Move const validator to post-validators so it validates the parsed value
* Fix model validation to handle nested literals
* Remove user_required = True from RedisDsn, neither user nor
password are required
* Remove extra allOf from schema for fields with Union and custom Field
* Updates OpenAPI schema generation to output all enums as separate
models. Instead of inlining the enum values in the model schema,
models now use a $ref property to point to the enum definition
-------------------------------------------------------------------
Tue Jun 9 19:24:27 UTC 2020 - Dirk Mueller <dmueller@suse.com>
- 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
-------------------------------------------------------------------
Sat Apr 18 19:11:39 UTC 2020 - Martin Hauke <mardnh@gmx.de>
- Update to version 1.5
* Make includes/excludes arguments for .dict(), ._iter(), ...,
immutable
* Always use a field's real name with includes/excludes in
model._iter(), regardless of by_alias, #1397 by @AlexECX
* Update constr regex example to include start and end lines,
* Confirm that shallow model.copy() does make a shallow copy of
attributes
* Renaming model_name argument of main.create_model()
to __model_name to allow using model_name as a field name
* Replace raising of exception to silent passing for non-Var
attributes in mypy plugin
* Remove typing_extensions dependency for python 3.8
* Make SecretStr and SecretBytes initialization idempotent
* document making secret types dumpable using the json method
* fix card number length check in PaymentCardNumber,
PaymentCardBrand now inherits from str
* Have BaseModel inherit from Representation to make mypy happy
when overriding __str__
* Allow None as input to all optional list fields
* Add datetime field to default_factory example
* Allow subclasses of known types to be encoded with superclass
encoder
* Exclude exported fields from all elements of a list/tuple of
submodels/dicts with '__all__', #1286 by @masalim2
* Add pydantic.color.Color objects as available input for Color
fields
* In examples, type nullable fields as Optional, so that these
are valid mypy annotations
* Make pattern_validator() accept pre-compiled Pattern objects.
Fix str_validator() return type to str
* Support instance methods and class methods with
@validate_arguments
* Add default_factory argument to Field to create a dynamic
default value by passing a zero-argument callable
* add support for NewType of List, Optional, etc
* fix mypy signature for root_validator
* Fixed parsing of nested 'custom root type' models
* Add validate_arguments function decorator which checks the
arguments to a function matches type annotations
* Add __signature__ to models
* Refactor ._iter() method, 10x speed boost for dict(model)
-------------------------------------------------------------------
Thu Mar 19 13:25:26 UTC 2020 - Marketa Calabkova <mcalabkova@suse.com>
- Update to version 1.4
* rename Schema to Field, make it a function to placate mypy
* Implement root_validator and rename root errors from __obj__ to __root__
* Added initvars support to post_init_post_parse
* complete rewrite of URL parsing logic
* BaseSettings now uses the special env settings to define which
environment variables to read, not aliases
* add support for assert statements inside validators
* Change the precedence of aliases so child model aliases override
parent aliases, including using alias_generator
* Add a mypy plugin for type checking BaseModel.__init__ and more
* Add support for typing.Literal for Python 3.8
* Add a ByteSize type for converting byte string (1GB) to plain bytes
* Add support for required Optional with name: Optional[AnyType] = Field(...)
and refactor ModelField creation to preserve required parameter value
* Add __eq__ to SecretStr and SecretBytes to allow "value equals"
* Add support for nested generic models
* alias precedence logic changed so aliases on a field always take
priority over an alias from alias_generator
* many more fixes and improvements
-------------------------------------------------------------------
Fri Sep 20 09:56:55 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Format with spec-cleaner
-------------------------------------------------------------------
Thu Sep 19 20:25:27 UTC 2019 - Martin Hauke <mardnh@gmx.de>
- Initial package, version 0.32.2

93
python-pydantic.spec Normal file
View File

@@ -0,0 +1,93 @@
#
# spec file for package python-pydantic
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2019, Martin Hauke <mardnh@gmx.de>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif
%{?sle15_python_module_pythons}
Name: python-pydantic%{psuffix}
Version: 2.7.4
Release: 0
Summary: Data validation and settings management using python type hinting
License: MIT
URL: https://github.com/pydantic/pydantic
Source: https://github.com/pydantic/pydantic/archive/v%{version}.tar.gz#/pydantic-%{version}.tar.gz
# PATCH-FIX-UPSTREAM gh#pydantic/pydantic#9527
Patch0: support-pytest-8.patch
BuildRequires: %{python_module hatch-fancy-pypi-readme}
BuildRequires: %{python_module hatchling}
BuildRequires: %{python_module packaging}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
%if %{with test}
BuildRequires: %{python_module Faker}
BuildRequires: %{python_module cloudpickle}
BuildRequires: %{python_module dirty-equals}
BuildRequires: %{python_module pydantic == %{version}}
BuildRequires: %{python_module pytest-benchmark}
BuildRequires: %{python_module pytest-examples}
BuildRequires: %{python_module pytest-mock}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module python-dotenv >= 0.10.4}
%endif
Requires: python-annotated-types >= 0.4.0
%if 0%{?python_version_nodots} < 310
Requires: python-eval-type-backport
%endif
Requires: python-pydantic-core == 2.18.4
Requires: python-typing_extensions >= 4.6.1
BuildArch: noarch
%python_subpackages
%description
Data validation and settings management using Python type hinting.
%prep
%autosetup -p1 -n pydantic-%{version}
%build
%pyproject_wheel
%install
%if %{without test}
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%endif
%check
%if %{with test}
%pytest
%endif
%if %{without test}
%files %{python_files}
%license LICENSE
%doc README.md HISTORY.md
%{python_sitelib}/pydantic
%{python_sitelib}/pydantic-%{version}.dist-info
%endif
%changelog

382
support-pytest-8.patch Normal file
View File

@@ -0,0 +1,382 @@
From 7fb31529124f51cceb32d1d7b8ae9b58c0606b17 Mon Sep 17 00:00:00 2001
From: Steve Kowalik <steven@wedontsleep.org>
Date: Thu, 30 May 2024 14:14:04 +1000
Subject: [PATCH] Ignore other warnings when checking warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Building on Michał's amazing work in PR#9040, extend the pattern to also
ignore other warnings that are emitted by pytest.warns() when running
under Pytest 8.x. This also continues to support Pytest 7.x.
Co-authored-by: Michał Górny <mgorny@gentoo.org>
Fixes: #9025
---
tests/conftest.py | 2 +-
tests/test_config.py | 84 +++++++++++---------
tests/test_deprecated.py | 156 ++++++++++++++++++++++----------------
tests/test_json_schema.py | 9 ++-
tests/test_validators.py | 1 +
5 files changed, 146 insertions(+), 106 deletions(-)
diff --git a/tests/conftest.py b/tests/conftest.py
index e0c0dee018..421afade2e 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -49,7 +49,7 @@ def _create_module_file(code, tmp_path, name):
def disable_error_urls():
# Don't add URLs during docs tests when printing
# Otherwise we'll get version numbers in the URLs that will update frequently
- os.environ['PYDANTIC_ERRORS_OMIT_URL'] = 'true'
+ os.environ['PYDANTIC_ERRORS_INCLUDE_URL'] = 'false'
@pytest.fixture
diff --git a/tests/test_config.py b/tests/test_config.py
index 1a5e31628a..31b2320326 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -1,6 +1,7 @@
import json
import re
import sys
+import warnings
from contextlib import nullcontext as does_not_raise
from decimal import Decimal
from inspect import signature
@@ -349,45 +350,54 @@ class Model(BaseModel):
assert m == m.model_copy()
def test_config_class_is_deprecated(self):
- with pytest.warns(
- PydanticDeprecatedSince20, match='Support for class-based `config` is deprecated, use ConfigDict instead.'
- ):
-
- class Config(BaseConfig):
- pass
+ with warnings.catch_warnings():
+ # we need to explicitly ignore the other warning in pytest-8
+ # TODO: rewrite it to use two nested pytest.warns() when pytest-7 is no longer supported
+ warnings.simplefilter('ignore')
+ with pytest.warns(
+ PydanticDeprecatedSince20,
+ match='Support for class-based `config` is deprecated, use ConfigDict instead.',
+ ):
+
+ class Config(BaseConfig):
+ pass
def test_config_class_attributes_are_deprecated(self):
- with pytest.warns(
- PydanticDeprecatedSince20,
- match='Support for class-based `config` is deprecated, use ConfigDict instead.',
- ):
- assert BaseConfig.validate_assignment is False
-
- with pytest.warns(
- PydanticDeprecatedSince20,
- match='Support for class-based `config` is deprecated, use ConfigDict instead.',
- ):
- assert BaseConfig().validate_assignment is False
-
- with pytest.warns(
- PydanticDeprecatedSince20,
- match='Support for class-based `config` is deprecated, use ConfigDict instead.',
- ):
-
- class Config(BaseConfig):
- pass
-
- with pytest.warns(
- PydanticDeprecatedSince20,
- match='Support for class-based `config` is deprecated, use ConfigDict instead.',
- ):
- assert Config.validate_assignment is False
-
- with pytest.warns(
- PydanticDeprecatedSince20,
- match='Support for class-based `config` is deprecated, use ConfigDict instead.',
- ):
- assert Config().validate_assignment is False
+ with warnings.catch_warnings():
+ # we need to explicitly ignore the other warning in pytest-8
+ # TODO: rewrite it to use two nested pytest.warns() when pytest-7 is no longer supported
+ warnings.simplefilter('ignore')
+ with pytest.warns(
+ PydanticDeprecatedSince20,
+ match='Support for class-based `config` is deprecated, use ConfigDict instead.',
+ ):
+ assert BaseConfig.validate_assignment is False
+
+ with pytest.warns(
+ PydanticDeprecatedSince20,
+ match='Support for class-based `config` is deprecated, use ConfigDict instead.',
+ ):
+ assert BaseConfig().validate_assignment is False
+
+ with pytest.warns(
+ PydanticDeprecatedSince20,
+ match='Support for class-based `config` is deprecated, use ConfigDict instead.',
+ ):
+
+ class Config(BaseConfig):
+ pass
+
+ with pytest.warns(
+ PydanticDeprecatedSince20,
+ match='Support for class-based `config` is deprecated, use ConfigDict instead.',
+ ):
+ assert Config.validate_assignment is False
+
+ with pytest.warns(
+ PydanticDeprecatedSince20,
+ match='Support for class-based `config` is deprecated, use ConfigDict instead.',
+ ):
+ assert Config().validate_assignment is False
@pytest.mark.filterwarnings('ignore:.* is deprecated.*:DeprecationWarning')
def test_config_class_missing_attributes(self):
diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py
index fda6879597..2e58e8b433 100644
--- a/tests/test_deprecated.py
+++ b/tests/test_deprecated.py
@@ -1,5 +1,6 @@
import platform
import re
+import warnings
from datetime import date, timedelta
from pathlib import Path
from types import SimpleNamespace
@@ -273,8 +274,12 @@ class Model(BaseModel):
x: int
y: int
- with pytest.warns(PydanticDeprecatedSince20, match='The `parse_raw` method is deprecated'):
- model = Model.parse_raw('{"x": 1, "y": 2}')
+ with warnings.catch_warnings():
+ # we need to explicitly ignore the other warning in pytest-8
+ # TODO: rewrite it to use two nested pytest.warns() when pytest-7 is no longer supported
+ warnings.simplefilter('ignore')
+ with pytest.warns(PydanticDeprecatedSince20, match='The `parse_raw` method is deprecated'):
+ model = Model.parse_raw('{"x": 1, "y": 2}')
assert model.model_dump() == {'x': 1, 'y': 2}
@@ -284,9 +289,13 @@ class Model(BaseModel):
x: int
y: int
- with pytest.warns(PydanticDeprecatedSince20, match='The `parse_raw` method is deprecated'):
- with pytest.raises(ValidationError, match='1 validation error for Model') as exc_info:
- Model.parse_raw('invalid')
+ with warnings.catch_warnings():
+ # we need to explicitly ignore the other warning in pytest-8
+ # TODO: rewrite it to use two nested pytest.warns() when pytest-7 is no longer supported
+ warnings.simplefilter('ignore')
+ with pytest.warns(PydanticDeprecatedSince20, match='The `parse_raw` method is deprecated'):
+ with pytest.raises(ValidationError, match='1 validation error for Model') as exc_info:
+ Model.parse_raw('invalid')
# insert_assert(exc_info.value.errors(include_url=False))
assert exc_info.value.errors(include_url=False) == [
@@ -435,10 +444,14 @@ class Model(BaseModel):
def test_field_include_deprecation():
m = '`include` is deprecated and does nothing. It will be removed, use `exclude` instead'
- with pytest.warns(PydanticDeprecatedSince20, match=m):
+ with warnings.catch_warnings():
+ # we need to explicitly ignore the other warning in pytest-8
+ # TODO: rewrite it to use two nested pytest.warns() when pytest-7 is no longer supported
+ warnings.simplefilter('ignore')
+ with pytest.warns(PydanticDeprecatedSince20, match=m):
- class Model(BaseModel):
- x: int = Field(include=True)
+ class Model(BaseModel):
+ x: int = Field(include=True)
def test_unique_items_items():
@@ -664,10 +677,14 @@ def test_parse_obj():
def test_parse_file(tmp_path):
path = tmp_path / 'test.json'
path.write_text('{"x": 12}')
- with pytest.warns(
- PydanticDeprecatedSince20, match='^The `parse_file` method is deprecated; load the data from file,'
- ):
- assert SimpleModel.parse_file(str(path)).model_dump() == {'x': 12}
+ with warnings.catch_warnings():
+ # we need to explicitly ignore the other warning in pytest-8
+ # TODO: rewrite it to use two nested pytest.warns() when pytest-7 is no longer supported
+ warnings.simplefilter('ignore')
+ with pytest.warns(
+ PydanticDeprecatedSince20, match='^The `parse_file` method is deprecated; load the data from file,'
+ ):
+ assert SimpleModel.parse_file(str(path)).model_dump() == {'x': 12}
def test_construct():
@@ -736,61 +753,68 @@ def test_deprecated_module(tmp_path: Path) -> None:
class Model(BaseModel):
x: int
- assert hasattr(parse_obj_as, '__deprecated__')
- with pytest.warns(
- PydanticDeprecatedSince20,
- match='`parse_obj_as` is deprecated. Use `pydantic.TypeAdapter.validate_python` instead.',
- ):
- parse_obj_as(Model, {'x': 1})
-
- assert hasattr(schema_json_of, '__deprecated__')
- with pytest.warns(
- PydanticDeprecatedSince20,
- match='`schema_json_of` is deprecated. Use `pydantic.TypeAdapter.json_schema` instead.',
- ):
- schema_json_of(Model)
-
- assert hasattr(schema_of, '__deprecated__')
- with pytest.warns(
- PydanticDeprecatedSince20, match='`schema_of` is deprecated. Use `pydantic.TypeAdapter.json_schema` instead.'
- ):
- schema_of(Model)
-
- assert hasattr(load_str_bytes, '__deprecated__')
- with pytest.warns(PydanticDeprecatedSince20, match='`load_str_bytes` is deprecated.'):
- load_str_bytes('{"x": 1}')
-
- assert hasattr(load_file, '__deprecated__')
- file = tmp_path / 'main.py'
- file.write_text('{"x": 1}')
- with pytest.warns(PydanticDeprecatedSince20, match='`load_file` is deprecated.'):
- load_file(file)
-
- assert hasattr(pydantic_encoder, '__deprecated__')
- with pytest.warns(
- PydanticDeprecatedSince20,
- match='`pydantic_encoder` is deprecated, use `pydantic_core.to_jsonable_python` instead.',
- ):
- pydantic_encoder(Model(x=1))
-
- assert hasattr(custom_pydantic_encoder, '__deprecated__')
- with pytest.warns(
- PydanticDeprecatedSince20, match='`custom_pydantic_encoder` is deprecated, use `BaseModel.model_dump` instead.'
- ):
- custom_pydantic_encoder({int: lambda x: str(x)}, Model(x=1))
-
- assert hasattr(timedelta_isoformat, '__deprecated__')
- with pytest.warns(PydanticDeprecatedSince20, match='`timedelta_isoformat` is deprecated.'):
- timedelta_isoformat(timedelta(seconds=1))
-
- with pytest.warns(
- PydanticDeprecatedSince20, match='The `validate_arguments` method is deprecated; use `validate_call` instead.'
- ):
-
- def test(a: int, b: int):
- pass
+ with warnings.catch_warnings():
+ # we need to explicitly ignore the other warning in pytest-8
+ # TODO: rewrite it to use two nested pytest.warns() when pytest-7 is no longer supported
+ warnings.simplefilter('ignore')
+ assert hasattr(parse_obj_as, '__deprecated__')
+ with pytest.warns(
+ PydanticDeprecatedSince20,
+ match='`parse_obj_as` is deprecated. Use `pydantic.TypeAdapter.validate_python` instead.',
+ ):
+ parse_obj_as(Model, {'x': 1})
+
+ assert hasattr(schema_json_of, '__deprecated__')
+ with pytest.warns(
+ PydanticDeprecatedSince20,
+ match='`schema_json_of` is deprecated. Use `pydantic.TypeAdapter.json_schema` instead.',
+ ):
+ schema_json_of(Model)
+
+ assert hasattr(schema_of, '__deprecated__')
+ with pytest.warns(
+ PydanticDeprecatedSince20,
+ match='`schema_of` is deprecated. Use `pydantic.TypeAdapter.json_schema` instead.',
+ ):
+ schema_of(Model)
+
+ assert hasattr(load_str_bytes, '__deprecated__')
+ with pytest.warns(PydanticDeprecatedSince20, match='`load_str_bytes` is deprecated.'):
+ load_str_bytes('{"x": 1}')
+
+ assert hasattr(load_file, '__deprecated__')
+ file = tmp_path / 'main.py'
+ file.write_text('{"x": 1}')
+ with pytest.warns(PydanticDeprecatedSince20, match='`load_file` is deprecated.'):
+ load_file(file)
+
+ assert hasattr(pydantic_encoder, '__deprecated__')
+ with pytest.warns(
+ PydanticDeprecatedSince20,
+ match='`pydantic_encoder` is deprecated, use `pydantic_core.to_jsonable_python` instead.',
+ ):
+ pydantic_encoder(Model(x=1))
+
+ assert hasattr(custom_pydantic_encoder, '__deprecated__')
+ with pytest.warns(
+ PydanticDeprecatedSince20,
+ match='`custom_pydantic_encoder` is deprecated, use `BaseModel.model_dump` instead.',
+ ):
+ custom_pydantic_encoder({int: lambda x: str(x)}, Model(x=1))
+
+ assert hasattr(timedelta_isoformat, '__deprecated__')
+ with pytest.warns(PydanticDeprecatedSince20, match='`timedelta_isoformat` is deprecated.'):
+ timedelta_isoformat(timedelta(seconds=1))
+
+ with pytest.warns(
+ PydanticDeprecatedSince20,
+ match='The `validate_arguments` method is deprecated; use `validate_call` instead.',
+ ):
+
+ def test(a: int, b: int):
+ pass
- validate_arguments()(test)
+ validate_arguments()(test)
def test_deprecated_color():
diff --git a/tests/test_json_schema.py b/tests/test_json_schema.py
index e6c60557a5..85d833c15c 100644
--- a/tests/test_json_schema.py
+++ b/tests/test_json_schema.py
@@ -5,6 +5,7 @@
import re
import sys
import typing
+import warnings
from datetime import date, datetime, time, timedelta
from decimal import Decimal
from enum import Enum, IntEnum
@@ -1385,8 +1386,12 @@ class Model(BaseModel):
class MyGenerator(GenerateJsonSchema):
ignored_warning_kinds = ()
- with pytest.warns(PydanticJsonSchemaWarning, match=warning_match):
- model_schema = Model.model_json_schema(schema_generator=MyGenerator)
+ with warnings.catch_warnings():
+ # we need to explicitly ignore the other warning in pytest-8
+ # TODO: rewrite it to use two nested pytest.warns() when pytest-7 is no longer supported
+ warnings.simplefilter('ignore')
+ with pytest.warns(PydanticJsonSchemaWarning, match=warning_match):
+ model_schema = Model.model_json_schema(schema_generator=MyGenerator)
assert model_schema == {
'properties': {'callback': {'title': 'Callback', 'type': 'integer'}},
'title': 'Model',
diff --git a/tests/test_validators.py b/tests/test_validators.py
index 52a8bda88f..b286c49b1b 100644
--- a/tests/test_validators.py
+++ b/tests/test_validators.py
@@ -2554,6 +2554,7 @@ class Model(BaseModel):
assert Model(x=1, y=2).model_dump() == {'x': 2, 'y': 3}
+@pytest.mark.filterwarnings('ignore:Pydantic V1 style `@root_validator` validators are deprecated.*:pydantic.warnings.PydanticDeprecatedSince20')
def test_root_validator_allow_reuse_same_field():
with pytest.warns(UserWarning, match='`root_val` overrides an existing Pydantic `@root_validator` decorator'):