Skip to content

Commit

Permalink
Revert typing.Literal and import it outside the TYPE_CHECKING block (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
frost-nzcr4 committed Apr 14, 2024
1 parent 2241983 commit 628f36b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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 @@ -125,7 +125,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 @@ -309,7 +309,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

0 comments on commit 628f36b

Please sign in to comment.