Skip to content

Daemon issues with retargeting re-exported names #6548

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

Open
msullivan opened this issue Mar 15, 2019 · 2 comments
Open

Daemon issues with retargeting re-exported names #6548

msullivan opened this issue Mar 15, 2019 · 2 comments

Comments

@msullivan
Copy link
Collaborator

Consider the following test:

[case testRetargetReexport]
from m import M

def f(x: M) -> None: ...

f(M())

[file m.py]
from n import M
[file m.py.2]
from q import M

[file n.py]
class M: ...

[file q.py]
class M: ...
[out]
==

The daemon fails in step two with the error
Argument 1 to "f" has incompatible type "q.M"; expected "n.M"

@msullivan msullivan added bug mypy got something wrong topic-fine-grained-incremental labels Mar 15, 2019
@msullivan
Copy link
Collaborator Author

There is a related seeming bug with NamedTuples whose names don't match their line numbers:

[case testRetargetReexportNamedTuple]
from m import M

def f(x: M) -> None: ...

f(M(0))

[file m.py]
from n import M

[file n.py]
from typing import NamedTuple
M = NamedTuple('_N', [('x', int)])

[file n.py.2]
# oh no
from typing import NamedTuple
M = NamedTuple('_N', [('x', int)])

[out]
==

Fails with Argument 1 to "f" has incompatible type "_N@3"; expected "_N@2"

Here it is also arguably a bug that the names get messed up like that, but it works if there is not a re-export...

@ilevkivskyi
Copy link
Member

I think I was also hit by this recently. I raise the priority to high, since this is a relatively large area where daemon's behavior is problematic.

msullivan added a commit that referenced this issue Apr 18, 2019
This lets us avoid inserting line numbers into the name when the
variable name and argument to NamedTuple disagree. This is good,
because the line numbers are ugly and when combined with bug #6548
causes problems when a namedtuple is reexported.
msullivan added a commit that referenced this issue Jan 15, 2020
This lets us avoid inserting line numbers into the name when the
variable name and argument to NamedTuple disagree. This is good,
because the line numbers are ugly and when combined with bug #6548
causes problems when a namedtuple is reexported.
msullivan added a commit that referenced this issue Feb 21, 2020
This lets us avoid inserting line numbers into the name when the
variable name and argument to NamedTuple disagree. This is good,
because the line numbers are ugly and when combined with bug #6548
causes problems when a namedtuple is reexported.
msullivan added a commit that referenced this issue May 28, 2020
This lets us avoid inserting line numbers into the name when the
variable name and argument to NamedTuple disagree. This is good,
because the line numbers are ugly and when combined with bug #6548
causes problems when a namedtuple is reexported.
msullivan added a commit that referenced this issue May 28, 2020
This lets us avoid inserting line numbers into the name when the
variable name and argument to NamedTuple disagree. This is good,
because the line numbers are ugly and when combined with bug #6548
causes problems when a namedtuple is reexported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants