Skip to content

Commit

Permalink
Add Deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Nov 28, 2023
1 parent a64f7e0 commit dbb3d2e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pydantic/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2822,3 +2822,17 @@ def __get_pydantic_core_schema__(cls, source_type: Any, handler: GetCoreSchemaHa
That is, instead of a [`ValidationError`][pydantic_core.ValidationError] being propagated up and the entire iterable being discarded
any invalid items are discarded and the valid ones are returned.
"""


# Can't use `Field(deprecated=True)` because of a circular import
Deprecated = Annotated[T, deprecated("")]
"""
Mark a field as being deprecated.
```py
from pydantic import Deprecated, TypeAdapter
print(TypeAdapter(Deprecated[int]).json_schema())
#> {'type': 'integer', 'deprecated': True}
"""

0 comments on commit dbb3d2e

Please sign in to comment.