fix behavior for dict and list

This commit is contained in:
Khaleel Al-Adhami 2024-10-04 17:35:45 -07:00
parent 510d47da53
commit 9e3dc2fc85

View File

@ -2834,6 +2834,9 @@ def dispatch(
).guess_type() ).guess_type()
V = TypeVar("V")
class Field(Generic[T]): class Field(Generic[T]):
"""Shadow class for Var to allow for type hinting in the IDE.""" """Shadow class for Var to allow for type hinting in the IDE."""
@ -2859,15 +2862,15 @@ class Field(Generic[T]):
@overload @overload
def __get__( def __get__(
self: Field[List[T]] | Field[Set[T]] | Field[Tuple[T, ...]], self: Field[List[V]] | Field[Set[V]] | Field[Tuple[V, ...]],
instance: None, instance: None,
owner, owner,
) -> ArrayVar[List[T]]: ... ) -> ArrayVar[List[V]]: ...
@overload @overload
def __get__( def __get__(
self: Field[Dict[str, T]], instance: None, owner self: Field[Dict[str, V]], instance: None, owner
) -> ObjectVar[Dict[str, T]]: ... ) -> ObjectVar[Dict[str, V]]: ...
@overload @overload
def __get__(self, instance: None, owner) -> Var[T]: ... def __get__(self, instance: None, owner) -> Var[T]: ...