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

kwargs typings are broken #6732

Open
alon-ba opened this issue Dec 4, 2024 · 6 comments
Open

kwargs typings are broken #6732

alon-ba opened this issue Dec 4, 2024 · 6 comments
Assignees
Labels
needs repro Issue has not been reproduced yet

Comments

@alon-ba
Copy link

alon-ba commented Dec 4, 2024

With Python 3.10

Following this issue:
#2541 (comment)

I tried to use it, and got 2 bugs:
#2541 (comment)

I also opened a bug for mypy:
python/mypy#18243 (comment)

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Dec 4, 2024
@rchiodo
Copy link
Contributor

rchiodo commented Dec 4, 2024

Sorry can you provide the information in this bug instead of adding comments to an older bug? Please reopen when you have the information.

@rchiodo rchiodo closed this as completed Dec 4, 2024
@alon-ba
Copy link
Author

alon-ba commented Dec 4, 2024

I tried to give typings to my kwargs, following this comment:
#2541 (comment)

But - It produced this bug for me:
In the case that my TypedDict is nested - it wouldn't auto-complete the fields of the inner TypedDict, if not all fields of OuterDict are given:
Image
Image

@rchiodo
Copy link
Contributor

rchiodo commented Dec 4, 2024

Okay thanks. I can reproduce the problem. I believe it's because when inside the inner_dict, it doesn't have a type for inner_dict unless the other keyword is supplied. It can't compute what inner_dict is supposed to be.

@rchiodo
Copy link
Contributor

rchiodo commented Dec 4, 2024

Here's the code I used:

from typing import Unpack, TypedDict

class InnerDict(TypedDict):
    a: int
    b: str

class OuterDict(TypedDict):
    inner: InnerDict
    field_1: str

def test_inner_dict(**kwargs: Unpack[OuterDict]):
    pass

test_inner_dict(inner={})

Completions for the inner only work if field_1 is also added to the args.

@alon-ba
Copy link
Author

alon-ba commented Dec 5, 2024

@rchiodo
Is there a possible fix or solution?

@rchiodo
Copy link
Contributor

rchiodo commented Dec 5, 2024

Is there a possible fix or solution?

Sorry but I don't know yet. It's not a very high priority item as it's not a regression and you're the first person to find the issue so it's unlikely I'll look into the solution anytime soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

2 participants