mirror of https://github.com/astral-sh/ruff
[ty] Fix `--exclude` and `src.exclude` merging (#21341)
This commit is contained in:
parent
ab46c8de0f
commit
f44598dc11
|
|
@ -589,6 +589,81 @@ fn explicit_path_overrides_exclude() -> anyhow::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_and_configuration_exclude() -> anyhow::Result<()> {
|
||||
let case = CliTest::with_files([
|
||||
(
|
||||
"src/main.py",
|
||||
r#"
|
||||
print(undefined_var) # error: unresolved-reference
|
||||
"#,
|
||||
),
|
||||
(
|
||||
"tests/generated.py",
|
||||
r#"
|
||||
print(dist_undefined_var) # error: unresolved-reference
|
||||
"#,
|
||||
),
|
||||
(
|
||||
"my_dist/other.py",
|
||||
r#"
|
||||
print(other_undefined_var) # error: unresolved-reference
|
||||
"#,
|
||||
),
|
||||
(
|
||||
"ty.toml",
|
||||
r#"
|
||||
[src]
|
||||
exclude = ["tests/"]
|
||||
"#,
|
||||
),
|
||||
])?;
|
||||
|
||||
assert_cmd_snapshot!(case.command(), @r"
|
||||
success: false
|
||||
exit_code: 1
|
||||
----- stdout -----
|
||||
error[unresolved-reference]: Name `other_undefined_var` used when not defined
|
||||
--> my_dist/other.py:2:7
|
||||
|
|
||||
2 | print(other_undefined_var) # error: unresolved-reference
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
info: rule `unresolved-reference` is enabled by default
|
||||
|
||||
error[unresolved-reference]: Name `undefined_var` used when not defined
|
||||
--> src/main.py:2:7
|
||||
|
|
||||
2 | print(undefined_var) # error: unresolved-reference
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
info: rule `unresolved-reference` is enabled by default
|
||||
|
||||
Found 2 diagnostics
|
||||
|
||||
----- stderr -----
|
||||
");
|
||||
|
||||
assert_cmd_snapshot!(case.command().arg("--exclude").arg("my_dist/"), @r"
|
||||
success: false
|
||||
exit_code: 1
|
||||
----- stdout -----
|
||||
error[unresolved-reference]: Name `undefined_var` used when not defined
|
||||
--> src/main.py:2:7
|
||||
|
|
||||
2 | print(undefined_var) # error: unresolved-reference
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
info: rule `unresolved-reference` is enabled by default
|
||||
|
||||
Found 1 diagnostic
|
||||
|
||||
----- stderr -----
|
||||
");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_include_pattern() -> anyhow::Result<()> {
|
||||
let case = CliTest::with_files([
|
||||
|
|
|
|||
|
|
@ -1186,6 +1186,16 @@ impl From<OutputFormat> for DiagnosticFormat {
|
|||
}
|
||||
}
|
||||
|
||||
impl Combine for OutputFormat {
|
||||
#[inline(always)]
|
||||
fn combine_with(&mut self, _other: Self) {}
|
||||
|
||||
#[inline]
|
||||
fn combine(self, _other: Self) -> Self {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Debug,
|
||||
Default,
|
||||
|
|
|
|||
|
|
@ -179,14 +179,13 @@ impl<T> RangedValue<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Combine for RangedValue<T> {
|
||||
fn combine(self, _other: Self) -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
self
|
||||
impl<T> Combine for RangedValue<T>
|
||||
where
|
||||
T: Combine,
|
||||
{
|
||||
fn combine_with(&mut self, other: Self) {
|
||||
self.value.combine_with(other.value);
|
||||
}
|
||||
fn combine_with(&mut self, _other: Self) {}
|
||||
}
|
||||
|
||||
impl<T> IntoIterator for RangedValue<T>
|
||||
|
|
|
|||
|
|
@ -7493,7 +7493,7 @@ impl<'db> VarianceInferable<'db> for Type<'db> {
|
|||
| Type::TypeAlias(_) => TypeVarVariance::Bivariant,
|
||||
};
|
||||
|
||||
tracing::debug!(
|
||||
tracing::trace!(
|
||||
"Result of variance of '{tvar}' in `{ty:?}` is `{v:?}`",
|
||||
tvar = typevar.typevar(db).name(db),
|
||||
ty = self.display(db),
|
||||
|
|
|
|||
Loading…
Reference in New Issue