-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
The below is in reference to this check added in #19653:
ruff/crates/ruff_linter/src/message/mod.rs
Lines 80 to 83 in 138188c
| // The `0..0` range is used to highlight file-level diagnostics. | |
| if range == TextRange::default() { | |
| annotation.set_file_level(true); | |
| } |
But this depends on the ability to cache Diagnostics more fully than we currently do in CacheMessage. The current caching scheme would lose the is_file_level flag on any Annotations.
Would it be much more work to instead change the rules that add file level diagnostics rather than doing this "global" override?
(the rule would have to mutate the
Diagnosticafter reporting it withreport_diagnostic).The reason I'd prefer this is that it makes it more apparent where we rely on this behavior and it doesn't prevent other rules to use an empty range (e.g. what if we had a rule that enforces module level docstrings. That rule would probably ask you to insert the docstring at 0:0.
Originally posted by @MichaReiser in #19653 (comment)