Open
Description
Hi,
Consider the following code, which passes with no error.
from foo import bar # type: ignore[import-not-found]
def baz(x: int):
return bar(*x, **x)
I think it would be neat to have mypy
raising error on this, since int
cannot be unpacked in any way.
Is it something to consider or am I missing something?
Thanks in advance.
Élie
Activity
sterliakov commentedon Mar 11, 2025
This is clearly a bug, unpacking should be checked consistently. It already happens if the callable is "good", but plain
Any
is not "good" enough. The same problem arises when the callable used is not a callable at all (e.g. a plainint
). playgroundAny
microsoft/pyright#10061hauntsaninja commentedon Mar 12, 2025
See related https://github.com/python/mypy/pull/18207/files and
check_any_type_call
if someone is interested in putting up a PRego-thales commentedon Mar 13, 2025
Hey,
I'm really not fluent in
mypy
source code and it's a bit hard to comprehend at first glance what is in charge of what.Is it a good starting point to look around here?
mypy/mypy/checkexpr.py
Lines 2484 to 2492 in e37d92d
I'm unsure because it seems that this would confront an actual call to a desired signature, whereas we only need to analyze the call here.
Also I could not really understand quickly how
check_any_type_call
should be looked at.sobolevn commentedon Mar 15, 2025
@ego-thales hi! Thanks for your interest. Here's a little prototype to help you working on this feature:
I didn't test this, but it should probably work :)
Jdwashin9 commentedon Apr 27, 2025
I'd like to work on this, too.
sobolevn commentedon Apr 27, 2025
@Jdwashin9 go ahead! My diff above can be a nice starting point.
ego-thales commentedon Apr 28, 2025
Oh thank you so much, because despite the really helpful contribution from @sobolevn, I could not find enough time to go further with this, requiring time to understand the core machanisms of the project. I had not forgotten, it still sat in my todo list, but it was not realistically going to happen before summer from my side.
Thanks in advance and good luck @Jdwashin9!