Fix crash when annotating callable definition location#3375
Fix crash when annotating callable definition location#3375ilevkivskyi merged 3 commits intopython:masterfrom
Conversation
|
I have no idea how to add test case for this. [case testUnexpectedKwargsDefinedHere]
import m
m.A(x=1) # E: Unexpected keyword argument "x" for "A"
[file m.py]
class A:
def __init__(self) -> None: # N: "A" defined here
passdoesn't trigger note, because |
|
@miedzinski if not defn._fullname:
defn._fullname = self.qualified_name(defn.name())in (also works with your test example above). |
|
Do you want me to include it with this patch or would you like to submit it yourself? |
Yes. |
|
And tests |
ilevkivskyi
left a comment
There was a problem hiding this comment.
Thanks! Looks good to me.
|
I just received a spurious message of the form The code to issue this message was modified by this PR. I have not been able to repro this "in the lab" yet (the above was part of a huge run on internal code), but I suspect that this might be related to an error in another file that was ignored by |
|
I also noticed that the spurious note seems to only appear with a cold |
|
I would propose an alternative solution. We could report the note on the same line as error, but report the source in the note itself, something like: Adding (TBH, this wording also seems nicer to me than the current one.) |
|
Finally it may be the case that what I saw was due to some filtering script we have that black-lists certain files. (But the |
|
Already said that on gitter: this is might have been introduced in this patch, mainly because of fix @ilevkivskyi proposed. Earlier methods lacked fullnames during 2nd pass, so the note wasn't triggered. |
|
A downside to @ilevkivskyi's solution is that I can't hit Enter in the Emacs |
Fixes #3362.