Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
Type ignore comments erroneously marked as unused by dmypy#15043
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
chadrik commentedApr 24, 2023
I ran into this issue testing a pre-release of 1.3 and it has created enough confusion on the team that I'm not sure we can roll it out until this is fixed. I would love to see this merged before release. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
710c001 to0b84c46Compare This comment has been minimized.
This comment has been minimized.
0b84c46 tofd8b35aCompare85b5144 tocca70fcCompare This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
b69fe5d to84271b0Compare This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
244c384 to84271b0Compare This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
JelleZijlstra commentedOct 28, 2023
The quotes shouldn't matter as this is a stub file, which isn't evaluated. The mutually recursive definition of Iterable and Iterator is indeed annoying to deal with, but mypy should be able to handle it. |
This comment was marked as outdated.
This comment was marked as outdated.
seddonym commentedDec 15, 2023
I'd like to try to help with this issue, and have some time next week. From what I understand, the PR fixes the underlying issue, but causes some apparently unrelated tests to fail in a surprising way. (The odd behaviour is limited to tests and doesn't happen if we run mypy for real.) I'm assuming this is a problem with the test machinery, and in particular with test fixtures that attempt to import My plan next week is to understand better what's going on by stepping through the test run in a debugger, but if anyone has any inkling as to what might be going on I'd be very grateful for any pointers.@chadrik or@JelleZijlstra I don't suppose you have any idea? |
seddonym commentedDec 18, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I've created a simple test case to show what is breaking. This test passes (but it shouldn't). This test is simulating the addition of a comment to an otherwise empty file. We are using the I'll continue to try to understand why this is... |
seddonym commentedDec 18, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Good news - I think I've got somewhere.This WIP commit gets the number of failing tests down to only 3. 🥳 BackgroundI noticed while debugging that there were some additional errors in the error list following the first check run. These aren't surfaced anywhere obvious, I happened to find these by putting a breakpoint in the final statement of Most of the errors were along these lines: These errors aren't present when I run it on master. How I fixed itI'm not sure if it's the correct thing to do, but I found adding @chadrik@JelleZijlstra Do you have any concerns with this as a fix? If so, please advise what would be a better thing to do. There were a couple of other test cases where instead the fix seemed to be just to add the appropriate Remaining failuresThe last three are a bit different - I'll continue to look at these tomorrow. Further contextThe reason for the more visible |
Uh oh!
There was an error while loading.Please reload this page.
meshy commentedJan 8, 2024
@CoolCat467 I've reproduced a crash on the I don't think that the crash I got is related to these changes, though as I said, I didn't get the same one as you. I've boiled it down to a minimal example, and added details of the crash in#14645 (comment) |
meshy commentedJan 9, 2024
@CoolCat467 I'm not able to reproduce your issue with the disappearing messages using the script in that repo. Can I please ask for detailed instructions on how to reproduce it? |
CoolCat467 commentedJan 9, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I have now updated Edit: I think the important detail was the fact I am telling dmypy absolute paths, because my use case of dmypy is as a code editor extension (idlemypyextension), where it might be quite important to tell the mypy daemon exactly which file we want it to check, because potentially the user changes projects without restarting the daemon and they might happen to have files named exactly the same way or whatnot. |
meshy commentedJan 9, 2024
@CoolCat467 Thank you for the clarification. I've got that working now, and can reproduce the dropped errors (on this branch and master). I'll try to turn this into a minimal test case. Curiously, I'm now not seeing the crash on the third command, but I'll come back to that later. |
meshy commentedJan 10, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The best minimal example I have so far:
[build-system]requires = ["setuptools >= 64"]build-backend ="setuptools.build_meta"[project]name ="dmypy_example"version ="0.0.1"dependencies = []
a:str=1 Commands: # Create a new Python 3.12 virtualenv, then:pip install --editable.dmypy run --export-types$(pwd)/src/foo.pydmypy run --export-types$(pwd)/src/foo.py Results: $pip install --editable....$dmypy run --export-types$(pwd)/src/foo.pyDaemon startedsrc/foo.py:1: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment]Found 1 error in 1 file (checked 1 source file)$dmypy run --export-types$(pwd)/src/foo.pySuccess: no issues found in 1 source file Notes:
My conclusion: It's disappointing that this branch doesn't fix this error, but I don't think that it'scaused by this branch, so perhaps we should consider this a new bug for handling separately? |
CoolCat467 commentedJan 10, 2024
Yea, I think it would make sense to make a new issue for this in particular.
I think this might be due to the project structure pip expects, but not completely sure Also side note, thank you for showing the use of |
meshy commentedJan 11, 2024
As far as I know,
I'm glad you found it useful! 🙂
Thanks! I've opened a new issue so we can track it there.#16768 |
The problem this solved has been addressed in another way, so we don'tneed to do this re-analysis any more in order to fix the bug we've beenchasing.This change is a partial revert of "Fix disappearing errors whenre-running dmypy check" from a few commits back.
According tomypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
meshy commentedSep 2, 2024
Hi all! It's been a while since I've had a look at this (I got a bit overwhelmed with it, TBH). I notice that this was considered for release in 1.9, but wasn't merged because"while the PR itself is apparently ok, it doesn't actually fix the issue completely that its trying to address". Am I right in saying thatthe issue discovered in this comment is the blocker? Before I go about investigating that, are there any other blockers that we're aware of? |
meshy commentedFeb 17, 2025
@jhance I wonder if you're able to help me answerthe question above, so that I might be able to continue on this? |
According tomypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
According tomypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
According tomypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
0755a61 intopython:masterUh oh!
There was an error while loading.Please reload this page.
meshy commentedJun 23, 2025
OMG you merged it! I love you! |
There is currently a misbehaviour where "type: ignore" comments areerroneously marked as unused in re-runs of dmypy. There are also caseswhere errors disappear on the re-run.As far as I can tell, this only happens in modules which contain animport that we don't know how to type (such as a module which does notexist), and a submodule which is unused.There was a lot of commenting and investigation on this PR, but I hopethat the committed tests and fixes illustrate and address the issue.Related to#9655---------Co-authored-by: David Seddon <david@seddonym.me>Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
There is currently a misbehaviour where "type: ignore" comments are erroneously marked as unused in re-runs of dmypy. There are also cases where errors disappear on the re-run.
As far as I can tell, this only happens in modules which contain an import that we don't know how to type (such as a module which does not exist), and a submodule which is unused.
There was a lot of commenting and investigation on this PR, but I hope that the committed tests and fixes illustrate and address the issue.
Related to#9655