mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-02 09:52:18 +00:00
686 B
686 B
Generic builtins
Variadic keyword arguments with a custom dict
When we define dict
in a custom typeshed, we must take care to define it as a generic class in the
same way as in the real typeshed.
[environment]
typeshed = "/typeshed"
/typeshed/stdlib/builtins.pyi
:
class object: ...
class int: ...
class dict[K, V, Extra]: ...
/typeshed/stdlib/typing_extensions.pyi
:
def reveal_type(obj, /): ...
If we don't, then we won't be able to infer the types of variadic keyword arguments correctly.
def f(**kwargs):
reveal_type(kwargs) # revealed: Unknown
def g(**kwargs: int):
reveal_type(kwargs) # revealed: Unknown