mohkale / flymake-collection

Collection of checkers for flymake
MIT License
68 stars 13 forks source link

Diagnostics from other source files aren't filtered #16

Open dmitrig opened 1 year ago

dmitrig commented 1 year ago

Some tools can report diagnostics from files other than the one currently being checked. These don't appear to be filtered out. Using flymake-collection-mypy on on the following package, for example:

foo
├── bar.py
├── baz.py
└── __init__.py

bar.py:

x = 1 + "y"

baz.py:

# This is a comment

from . import bar

I get a diagnostic on baz.py:1:8 due to the type error in bar.py.

mohkale commented 1 year ago

This kind of seems like a bug in mypy. I'm not all that enthusiastic about stripping out lints based on which directly match the original buffer. Perhaps point this out to the mypy devs as a potential bug.

dmitrig commented 1 year ago

Not sure I agree -- mypy is reporting the location of the error accurately, and it's relevant to why checking baz.py may not work as expected.

If I understand the docs correctly, flymake explicitly supports backends that work this way, it just requires passing through the source file of the diagnostic.

mohkale commented 1 year ago

@dmitrig

You raise a good point, and thanks for the reference to the docs. I wasn't aware of foreign diagnostics but the use case and support makes sense. I'd be happy to accept a PR to amend the existing checker generation function to support foreign diagnostics as well.