[ty] Ignore possibly-unresolved-reference by default (#17934)

This commit is contained in:
Micha Reiser 2025-05-08 17:44:56 +02:00 committed by GitHub
parent 067a8ac574
commit d608eae126
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 97 additions and 72 deletions

View file

@ -59,7 +59,7 @@ info: revealed-type: Revealed type
```
```
warning: lint:possibly-unresolved-reference: Name `x` used when possibly not defined
info: lint:possibly-unresolved-reference: Name `x` used when possibly not defined
--> src/mdtest_snippet.py:16:17
|
14 | # revealed: Unknown

View file

@ -475,12 +475,26 @@ impl RuleSelection {
/// Creates a new rule selection from all known lints in the registry that are enabled
/// according to their default severity.
pub fn from_registry(registry: &LintRegistry) -> Self {
Self::from_registry_with_default(registry, None)
}
/// Creates a new rule selection from all known lints in the registry, including lints that are default by default.
/// Lints that are disabled by default use the `default_severity`.
pub fn all(registry: &LintRegistry, default_severity: Severity) -> Self {
Self::from_registry_with_default(registry, Some(default_severity))
}
fn from_registry_with_default(
registry: &LintRegistry,
default_severity: Option<Severity>,
) -> Self {
let lints = registry
.lints()
.iter()
.filter_map(|lint| {
Severity::try_from(lint.default_level())
.ok()
.or(default_severity)
.map(|severity| (*lint, (severity, LintSource::Default)))
})
.collect();

View file

@ -851,7 +851,7 @@ declare_lint! {
pub(crate) static POSSIBLY_UNRESOLVED_REFERENCE = {
summary: "detects references to possibly undefined names",
status: LintStatus::preview("1.0.0"),
default_level: Level::Warn,
default_level: Level::Ignore,
}
}