flake8-pyi
flake8-pyi copied to clipboard
Encourage typing_extensions.Unpack for many overload-invariant keywords
If a function has many keyword arguments that do not change across all overloads (for example pandas.read_csv). It is more readable and shorter to move all the overload-invariant keywords into a TypedDict and suggest using the Unpack
feature which is supported by at least pyright and mypy.
This would probably need some heuristic of when is it worth recommending Unpack: Using a TypedDict for less than insert magic number
keywords is probably not helpful.
We shouldn't do this in typeshed until PEP 692 is accepted. I think it's better to also wait in flake8-pyi.
We shouldn't do this in typeshed until PEP 692 is accepted. I think it's better to also wait in flake8-pyi.
Yeah, I agree. Hopefully the PEP will be accepted, but until then this is essentially an unofficial/unsanctioned use of this symbol, so I'm not sure we should write a lint enforcing its use just yet. I'll mark this as "deferred" for now :)
The PEP's been accepted now, but mypy's support is still guarded behind --enable-incomplete-feature=Unpack
(our typeshed trackig issue is https://github.com/python/typeshed/issues/9710). We probably shouldn't write a lint encouraging it until it's properly supported by all major type checkers.