Skip to content
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

mypy and dmypy run are not agreeing #15214

Closed
alanhdu opened this issue May 9, 2023 · 3 comments · Fixed by #15259
Closed

mypy and dmypy run are not agreeing #15214

alanhdu opened this issue May 9, 2023 · 3 comments · Fixed by #15259
Labels
bug mypy got something wrong

Comments

@alanhdu
Copy link
Contributor

alanhdu commented May 9, 2023

Bug Report

I'm not sure if I misunderstood the documentation, but I assumed that mypy and dmypy run would should always return the same thing when run on the same code. This does not seem to be the case though:

To Reproduce

If I have the simple file:

_var = None

def set_var():
    global _var
    if not _var:
        _var = 1
    return _var

then mypy foo.py gives success, while dmypy run -- foo.py reports:

Daemon started
mypy foo.py
foo.py:3: error: Need type annotation for "_var" (hint: "_var: Optional[<type>] = ...")  [var-annotated]
Found 1 error in 1 file (checked 44 source files)

This is on both mypy 1.2.0 (compiled: yes) and mypy 1.4.0+dev.35acb1bf69c990fcd89eeec32e35ae21f93c2d84 (compiled: no).

Expected Behavior

I would've expected either both of them to fail with the same error, or both of them to succeed. Alternatively, I would've expected the docs to spell out what the configuration differences are between mypy and dmypy

@alanhdu alanhdu added the bug mypy got something wrong label May 9, 2023
@hauntsaninja
Copy link
Collaborator

@alanhdu
Copy link
Contributor Author

alanhdu commented May 11, 2023

Ah -- of course, I must have missed that when reading the docs. Would you be open to adding a note in https://mypy.readthedocs.io/en/stable/mypy_daemon.html to make that clearer (I'd be happy to open a PR), or is it going to be enabled by default soon enough that we shouldn't bother?

@hauntsaninja
Copy link
Collaborator

Yes, a note sounds good! I'm not sure there's a concrete timeline towards making it the default (last time it was consciously thought about was to not do it as part of the 1.0 release)

hauntsaninja pushed a commit that referenced this issue May 18, 2023
Fixes #15214 but adding a note to
the dmypy docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants