Skip to content

Commit 068b0b4

Browse files
authored
Improve builtins.vars() (#9146)
1 parent 796bdc2 commit 068b0b4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

stdlib/builtins.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,8 +1666,12 @@ else:
16661666
@overload
16671667
def sum(__iterable: Iterable[_AddableT1], __start: _AddableT2) -> _AddableT1 | _AddableT2: ...
16681668

1669-
# The argument to `vars()` has to have a `__dict__` attribute, so can't be annotated with `object`
1669+
# The argument to `vars()` has to have a `__dict__` attribute, so the second overload can't be annotated with `object`
16701670
# (A "SupportsDunderDict" protocol doesn't work)
1671+
# Use a type: ignore to make complaints about overlapping overloads go away
1672+
@overload
1673+
def vars(__object: type) -> types.MappingProxyType[str, Any]: ... # type: ignore[misc]
1674+
@overload
16711675
def vars(__object: Any = ...) -> dict[str, Any]: ...
16721676

16731677
class zip(Iterator[_T_co], Generic[_T_co]):

0 commit comments

Comments
 (0)