8000 ✏️ Invert order of `typing` <-> `typing_extensions` by Kludex · Pull Request #6359 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content

✏️ Invert order of typing <-> typing_extensions #6359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
8000 Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix message
  • Loading branch information
Kludex committed Jul 2, 2023
commit 3e60c77449e298a54f3c9a0d18f01aef9773f358
2 changes: 1 addition & 1 deletion docs/usage/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ except PydanticUserError as exc_info:

## `TypedDict` version {#typed-dict-version}

This error is raised when you use `typing.TypedDict` instead of `typing_extensions.TypedDict` on Python < 3.12.
This error is raised when you use `typing.TypedDict` instead of `typing_extensions.TypedDict` on Python < 3.11.

## Model parent field overridden {#model-field-overridden}

Expand Down
6 changes: 3 additions & 3 deletions pydantic/_internal/_generate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
from ._dataclasses import StandardDataclass
from ._schema_generation_shared import GetJsonSchemaFunction

_SUPPORTS_TYPEDDICT = sys.version_info >= (3, 12)
_SUPPORTS_TYPEDDICT = sys.version_info >= (3, 11)

FieldDecoratorInfo = Union[ValidatorDecoratorInfo, FieldValidatorDecoratorInfo, FieldSerializerDecoratorInfo]
FieldDecoratorInfoType = TypeVar('FieldDecoratorInfoType', bound=FieldDecoratorInfo)
Expand Down Expand Up @@ -256,7 +256,7 @@ def generate_schema(
- If `alias_generator` returns a non-string value.
- If V1 style validator with `each_item=True` applied on a wrong field.
PydanticUserError:
- If `typing.TypedDict` is used instead of `typing_extensions.TypedDict` on Python < 3.12.
- If `typing.TypedDict` is used instead of `typing_extensions.TypedDict` on Python < 3.11.
- If `__modify_schema__` method is used instead of `__get_pydantic_json_schema__`.
"""
if isinstance(obj, type(Annotated[int, 123])):
Expand Down Expand Up @@ -794,7 +794,7 @@ def _typed_dict_schema(self, typed_dict_cls: Any, origin: Any) -> core_schema.Co

if not _SUPPORTS_TYPEDDICT and type(typed_dict_cls).__module__ == 'typing':
raise PydanticUserError(
'Please use `typing_extensions.TypedDict` instead of `typing.TypedDict` on Python < 3.12.',
'Please use `typing_extensions.TypedDict` instead of `typing.TypedDict` on Python < 3.11.',
code='typed-dict-version',
)

Expand Down
0