8000 Fix type hint of `Field.default` to be compatible with Python 3.8 and… · pydantic/pydantic@a9cf39c · GitHub
[go: up one dir, main page]

Skip to content

Commit a9cf39c

Browse files
Viicossydney-runkle
authored andcommitted
Fix type hint of Field.default to be compatible with Python 3.8 and 3.9 (#10972)
For Python < 3.10, we define `EllipsisType = type(Ellipsis)` in `_typing_extra`. `EllipsisType` is then used in a type expression but pyright raises an error because `EllipsisType` is defined as variable. Instead, we make use of the `ellipsis` builtin, only available for type checkers (defined in typeshed) as a compatibility hack.
1 parent 869eafd commit a9cf39c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pydantic/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ class _EmptyKwargs(typing_extensions.TypedDict):
734734
# to understand the magic that happens at runtime with the following overloads:
735735
@overload # type hint the return value as `Any` to avoid type checking regressions when using `...`.
736736
def Field(
737-
default: _typing_extra.EllipsisType,
737+
default: ellipsis, # noqa: F821 # TODO: use `_typing_extra.EllipsisType` when we drop Py3.9
738738
*,
739739
alias: str | None = _Unset,
740740
alias_priority: int | None = _Unset,

0 commit comments

Comments
 (0)
0