-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
NotImplementedError in map_actuals_to_formals #1553
Comments
Here's a smaller repro: def xget(section, subsection):
pass
def aget(*args, **kwds):
return xget(*args, **kwds)
def foo(i):
args = ('x', 'y')
return aget(*args) # <----- error The explicit |
Has this been fixed already? Running Mypy on @gvanrossum's example now prints nothing. |
@The-Compiler Can you confirm? Indeed my little example doesn't crash any more. Most likely @rwbarton fixed this as a side effect of one of his other fixes. |
Unfortunately I can still reproduce this with the current master and my code - no time right now to investigate more though, sorry! |
Thanks for the confirmation! We'll keep it open. Is the code that
reproduces this in your repo?
|
Indeed. You should be able to clone https://github.com/The-Compiler/qutebrowser, check out the |
I just found a smaller repro: t = (1, 2)
'{} {}'.format(*t) |
Here's a python2 repro we hit:
Notice how the existence of the **kw is what causes this to happen. |
Smallest test case yet: def f(**kw): pass
f(*(1, 2)) |
I'm sure this has something to do with the case analysis for "arg_kind" and
the special-casing there for tuple unpacking.
|
Simply commenting out these lines seems to fix the issue and not introduce any worse bugs, though I can't be sure... |
Well, something is clearly hitting the else branch there, so the question
is what the various variables are at that point. Could you come up with
some test?
|
Adding
Seems to be that mypy is trying to map the |
I think we shouldn't be advancing through Another case that mypy crashes on is when there's no |
Actually, it's possible that the
But apart from that Reid's right! |
Hm, I was hoping that matching up the def foo(a: int, *args: str) -> None: ...
args = (1, 'b', 'c') # type: Tuple[int, str, str]
foo(*args) # Should be allowed In order to support this we'd have to understand that callee argument 2 corresponds to a subsequence of caller argument 1. We could just not handle this case for now though (we would reject some valid programs like the above). |
Would be nice if for all combinations it either worked or emitted a polite
error rather than crashing. I think we have enough information about tuples
though to be able to compute that subsequence. Do we do this for slices or
unpacking?
|
Moving the milestone closer as this keeps coming up. |
Even smaller test case: tail = ['b', 'c']
['a', *tail] This bug is probably related to #704. |
@jirutka: No, that's a repro for the issue mentioned in #704 but the traceback is different from what this issue is about. You can either add your repro to #704 or file a new issue to call it out (since #704 is really about introducing support for PEP 448 -- if mypy just gave an error saying "Syntax error" instead of a crash that would be a start). |
Okay, I’ve opened new issue #1890. |
I'm tired of this particular crash (it hits a lot of people) so in #1891 I'm applying what is essentially @kirbyfan64's proposal: just delete the Skimming the code it looks like there are other cases that aren't handled properly. But my first instinct is to try to raise an error, which is impossible, because map_actuals_to_formals() has no argument giving access to the Errors instance in use, nor the context needed for the line number. So I'm content with fixing the crash -- I'm going to report other error cases (if I can find any) in a new issue. |
When I run mypy (0.4 or git master with Python 3.5) with
--check-untyped-defs
over qutebrowser, I get:I wasn't able to construct a minimal example which fails in the same way, but it fails on this line:
Some interesting locals from a
--pdb
session:Seems like the
4
for the current argument (j=1
) isnodes.UNBOUND_TVAR
.The text was updated successfully, but these errors were encountered: