Content-Length: 243832 | pFad | https://github.com/googleapis/google-cloud-python/issues/8545

F6 Typing kwargs as dict can cause issues with type hinting systems · Issue #8545 · googleapis/google-cloud-python · GitHub
Skip to content

Typing kwargs as dict can cause issues with type hinting systems #8545

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

Closed
crwilcox opened this issue Jul 1, 2019 · 0 comments
Closed

Typing kwargs as dict can cause issues with type hinting systems #8545

crwilcox opened this issue Jul 1, 2019 · 0 comments
Assignees

Comments

@crwilcox
Copy link
Contributor

crwilcox commented Jul 1, 2019

Thanks to @retnikt for opening #7422. This issue is tracking that and will have an accompanying PR that more broadly fixes the issue.

When typing Python code, the special *args and **kwargs params are typed based on their contents, not what they actually are (a tuple, and a dict) e.g.

def foo(thing: int, *args: str):
...
def bar(thing: int, *args: str, **kwargs: Union[int, float]):
...

bar(-3, "G", spam=80, eggs=4.4)
foo(44, "abc", "xyz")
And in this case, the types are passed to a different func (Query.init) which has specific arguments, so it is best to not give **kwargs a type, or, better, copy the parameters of that function (but I haven't done this here).
This also applies to Transaction.
PS I know this is a stupidly minor change but it annoys me, having to write noinspection PyTypeChecker before every datastore query.
😄

crwilcox pushed a commit that referenced this issue Jul 1, 2019
crwilcox pushed a commit that referenced this issue Jul 1, 2019
crwilcox added a commit that referenced this issue Jul 1, 2019
parthea pushed a commit that referenced this issue Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/googleapis/google-cloud-python/issues/8545

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy