Merged
Conversation
MichaReiser
commented
Jan 21, 2025
| Arc::into_inner(result).unwrap().into_inner().unwrap() | ||
| } | ||
|
|
||
| pub(crate) fn check_file(self, db: &dyn Db, file: File) -> Vec<Box<dyn Diagnostic>> { |
Member
Author
There was a problem hiding this comment.
I included the rule diagnostics in check_file because an API consumer (e.g., the LSP) can decide only to call check_file but never project.check and would never see the diagnostics.
The counter-argument is that these diagnostics aren't related to file so they shouldn't be shown.
I'm not sure what the right answer is, but I defaulted to including them for now.
Contributor
|
54ca21c to
af3bbde
Compare
0bf7453 to
3a4b7f0
Compare
dcreager
added a commit
that referenced
this pull request
Jan 24, 2025
* main: [red-knot] MDTests: Do not depend on precise public-symbol type inference (#15691) [red-knot] Make `infer.rs` unit tests independent of public symbol inference (#15690) Tidy knot CLI tests (#15685) [red-knot] Port comprehension tests to Markdown (#15688) Create Unknown rule diagnostics with a source range (#15648) [red-knot] Port 'deferred annotations' unit tests to Markdown (#15686) [red-knot] Support custom typeshed Markdown tests (#15683) Don't run the linter ecosystem check on PRs that only touch red-knot crates (#15687) Add `rules` table to configuration (#15645) [red-knot] Make `Diagnostic::file` optional (#15640) [red-knot] Add test for nested attribute access (#15684) [red-knot] Anchor relative paths in configurations (#15634) [`pyupgrade`] Handle multiple base classes for PEP 695 generics (`UP046`) (#15659) [`pyflakes`] Treat arguments passed to the `default=` parameter of `TypeVar` as type expressions (`F821`) (#15679) Upgrade zizmor to the latest version in CI (#15649) [`pyupgrade`] Add rules to use PEP 695 generics in classes and functions (`UP046`, `UP047`) (#15565) [red-knot] Ensure a gradual type can always be assigned to itself (#15675)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for enabling or disabling a rule or change its severity to warning by using a configuration file.
This PR doesn't yet add support for the
rule = { severity="level" }format simply because we don't support any per-rule configurations other thanseverityjust yet (like fixability). We should add support once for a sub-table once we add support for it. This PR also does not yet add support for configuring rules over the CLI.The "hardest" part of this PR was to make the diagnostics propagate. The approach
I've taken for now is to simply collect them when calling
project.checkorproject.check_file.I don't love this approach because it's somewhat easy to get wrong and we have to repeat it in
every entry function that may return diagnostics (e.g.
format?). However,we currently only exactly have two, so it sort of feels okay?
I considered using salsa accumulators but doing so wouldn't solve
the problem that we have to remember collecting the diagnostics
in the
project.checkcall, but we could use them if we want,performance isn't as much of a concern here.
Overall I felt like defering the ideal design until we have
more settings that require validation to get a better sense of
how awkward (or good) the current design is.
The diagnostics for unknown rules currently lack any source information. I plan on adding proper spans in a follow-up PR because it requires some machinery to funnel the spans through serde.
CC @BurntSushi: I don't consider the "how we funnel diagnostics through red knot" as the main focus of your diagnostics work but I thought this might still be interesting to you.
Part of astral-sh/ty#219
Test Plan
Added CLI tests.