Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encourage typing_extensions.Unpack for many overload-invariant keywords #285

Open
twoertwein opened this issue Sep 28, 2022 · 3 comments
Open
Labels

Comments

@twoertwein
Copy link
Contributor

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.

@JelleZijlstra
Copy link
Collaborator

We shouldn't do this in typeshed until PEP 692 is accepted. I think it's better to also wait in flake8-pyi.

@AlexWaygood
Copy link
Collaborator

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 :)

@AlexWaygood
Copy link
Collaborator

AlexWaygood commented May 1, 2023

The PEP's been accepted now, but mypy's support is still guarded behind --enable-incomplete-feature=Unpack (our typeshed trackig issue is python/typeshed#9710). We probably shouldn't write a lint encouraging it until it's properly supported by all major type checkers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants