You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have recently encountered this on 1.0.1. I have not yet produced a minimal example.
In my case the bulk of the unused type: ignore warnings which disappear are on lines that have been typed by the django-stubs project. I wonder if it may have something to do with that project, or with plugins in general.
I have a new example that doesn't have any external requirements.
unused/__init__.py
(empty file)
unused/empty.py
(empty file)
example.py
fromunused.emptyimport*a=1# type: ignore
Instructions (in a clean virtualenv)
$ dmypy stopDaemon stopped
$ dmypy run -- --package example --warn-unused-ignoresDaemon startedexample.py:2: error: Unused "type: ignore" commentFound 1 error in 1 file (checked 46 source files)
$ dmypy run -- --package example --warn-unused-ignoresSuccess: no issues found in 1 source file
From what I can tell this issue happens when we call fine_grained_manager.update([], to_delete) in dmypy_server.Server.fine_grained_increment_follow_imports.
In this case, to_delete is [('unused', '/.../mypy-9655/unused/__init__.py')].
For some reason, when this update is made, the Unused "type: ignore" comment also goes missing.
Next up: dig into mypy, and work out what's going on.
EDIT: I have created a failing test based on this example, and continue to investigate a fix.
@meshy Using #15043, I can confirm that Unused "type: ignore" comment errors seem to appear everytime dmypy is ran, without having to restart the daemon. 👌🏻
The error on line 5 isn't reported on the second step.
The root cause is that we don't report unused type ignores in nodes only processed using reprocess_nodes, i.e. when following fine-grained dependencies or reprocessing nodes that previously generated errors.
I think this is a potential way to fix this (but I haven't thought about this very carefully yet):
Collect a set of all the triggered/processed nodes in propagate_changes_using_dependencies.
At the end of a daemon update, perform the equivalent of generate_unused_ignore_notes, but only report errors within the previously triggered nodes. The filtering step seems necessary, as some parts of modules are often not processed during a fine-grained increment.
Ah, I forgot to mention that the test cases I mentioned above aren't specifically covered by #15043 yet. It's okay to leave fixing these for another PR, but we shouldn't close this issue until all known cases are fixed.
Activity
jgillard commentedon Mar 30, 2022
I noticed this today with mypy 0.942, so this is still an issue.
peterbygrave commentedon Nov 30, 2022
This is still a problem in 0.991
AlexWaygood commentedon Nov 30, 2022
Has anybody managed to find a reproducible example yet?
meshy commentedon Feb 20, 2023
I have recently encountered this on 1.0.1. I have not yet produced a minimal example.
In my case the bulk of the
unused type: ignorewarnings which disappear are on lines that have been typed by thedjango-stubsproject. I wonder if it may have something to do with that project, or with plugins in general.meshy commentedon Feb 27, 2023
meshy commentedon Mar 3, 2023
I have a new example that doesn't have any external requirements.
unused/__init__.py(empty file)
unused/empty.py(empty file)
example.pyInstructions (in a clean virtualenv)
From what I can tell this issue happens when we call
fine_grained_manager.update([], to_delete)indmypy_server.Server.fine_grained_increment_follow_imports.In this case,
to_deleteis[('unused', '/.../mypy-9655/unused/__init__.py')].For some reason, when this update is made, the
Unused "type: ignore" commentalso goes missing.Next up: dig into
mypy, and work out what's going on.EDIT: I have created a failing test based on this example, and continue to investigate a fix.
Add test to demonstrate issue python#9655
Prove ignores without error codes also disappear
Prove ignores without error codes also disappear
Prove possibly-undefined errors disappear
Ensure errors persist after dmypy update
Ensure errors persist after dmypy update
46 remaining items
meshy commentedon Jan 2, 2024
If anyone following this thread is able to check if #15043 works for them, I'd appreciate the feedback.
m-honel-ywh2bt commentedon Jan 2, 2024
@meshy Using #15043, I can confirm that
Unused "type: ignore" commenterrors seem to appear everytime dmypy is ran, without having to restart the daemon. 👌🏻Fix disappearing errors when re-running dmypy check
Add a regression test for type ignores in dmypy
JukkaL commentedon Feb 5, 2024
I think there is another case where type ignore comments still aren't being reported. Here are a few failing test cases:
The error on line 5 isn't reported on the second step.
The root cause is that we don't report unused type ignores in nodes only processed using
reprocess_nodes, i.e. when following fine-grained dependencies or reprocessing nodes that previously generated errors.I think this is a potential way to fix this (but I haven't thought about this very carefully yet):
propagate_changes_using_dependencies.generate_unused_ignore_notes, but only report errors within the previously triggered nodes. The filtering step seems necessary, as some parts of modules are often not processed during a fine-grained increment.meshy commentedon Feb 5, 2024
@JukkaL good catch.
Do you think this blocks #15043, or could we tackle that case separately?
JukkaL commentedon Feb 5, 2024
Ah, I forgot to mention that the test cases I mentioned above aren't specifically covered by #15043 yet. It's okay to leave fixing these for another PR, but we shouldn't close this issue until all known cases are fixed.
meshy commentedon Feb 5, 2024
OK great, thank you. I've removed the "fixes" comment from that PR so we avoid closing this issue.
Add test to demonstrate issue python#9655
Prove ignores without error codes also disappear
Prove possibly-undefined errors disappear
Fix disappearing errors when re-running dmypy check
Add a regression test for type ignores in dmypy
Type ignore comments erroneously marked as unused by dmypy (#15043)
Type ignore comments erroneously marked as unused by dmypy (#15043)