Skip to content
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

Revert typing.Literal and import it outside the TYPE_CHECKING block #9232

Merged
merged 1 commit into from Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pydantic/_internal/_std_types_schema.py
Expand Up @@ -15,7 +15,7 @@
from functools import partial
from ipaddress import IPv4Address, IPv4Interface, IPv4Network, IPv6Address, IPv6Interface, IPv6Network
from operator import attrgetter
from typing import Any, Callable, Iterable, TypeVar
from typing import Any, Callable, Iterable, Literal, TypeVar

import typing_extensions
from pydantic_core import (
Expand Down Expand Up @@ -67,7 +67,7 @@ def get_enum_core_schema(enum_type: type[Enum], config: ConfigDict) -> CoreSchem
js_updates = {'title': enum_type.__name__, 'description': description}
js_updates = {k: v for k, v in js_updates.items() if v is not None}

sub_type: typing_extensions.Literal['str', 'int', 'float'] | None = None
sub_type: Literal['str', 'int', 'float'] | None = None
if issubclass(enum_type, int):
sub_type = 'int'
value_ser_type: core_schema.SerSchema = core_schema.simple_ser_schema('int')
Expand Down
4 changes: 2 additions & 2 deletions pydantic/main.py
Expand Up @@ -124,7 +124,7 @@ class BaseModel(metaclass=_model_construction.ModelMetaclass):
__pydantic_decorators__: ClassVar[_decorators.DecoratorInfos]
__pydantic_generic_metadata__: ClassVar[_generics.PydanticGenericMetadata]
__pydantic_parent_namespace__: ClassVar[dict[str, Any] | None]
__pydantic_post_init__: ClassVar[None | typing_extensions.Literal['model_post_init']]
__pydantic_post_init__: ClassVar[None | Literal['model_post_init']]
__pydantic_root_model__: ClassVar[bool]
__pydantic_serializer__: ClassVar[SchemaSerializer]
__pydantic_validator__: ClassVar[SchemaValidator]
Expand Down Expand Up @@ -290,7 +290,7 @@ def model_copy(self: Model, *, update: dict[str, Any] | None = None, deep: bool
def model_dump(
self,
*,
mode: typing_extensions.Literal['json', 'python'] | str = 'python',
mode: Literal['json', 'python'] | str = 'python',
include: IncEx = None,
exclude: IncEx = None,
context: dict[str, Any] | None = None,
Expand Down