Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed
@crwilcox

Description

@crwilcox
Issue body actions

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.
😄

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.