-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Type Check Function Invocations with **Kwargs #8485
Comments
Yeah, it's possible mypy could infer the TypedDict type there, on the lines of #5382 (comment) |
I realized I tried using |
This is essentially a duplicate of #5382 |
This seems superficially related to other kwargs issues, but from what I've read those mostly related to annotating a function so that its signature matches another function. I want to annotate a dictionary so that it's type is whatever is allowed as
kwargs
to a particular function (or even better, if mypy can simply handle the case where a dictionaryd
is created and then immediately passed into a function with**
with nothing in between).We recently refactored
to
In order to improve our log messages without being redundant. We were surprised that
mypy
is no longer useful for checking that the arguments we pass in match the parameters thatLambdaClient.invoke
expects.Is there a (non-redundant) way to type hint
params
such that mypy doesn't give me errors, but if a key is added toparams
dict which would be illegal to pass toLambdaClient.invoke
then it is caught bymypy
? I assume that if its possible at all, I would need something likeTypeOf[LambdaClient.invoke]
.Currently I get the following output from
mypy
post-refactor:To get mypy to validate the call to
invoke
I need to do something very redundant like:I did also try annotating
params
withFinal
to helpmypy
understand that it would not change between declaration and the invocation, however that did not change the type checking result.The text was updated successfully, but these errors were encountered: