diff --git a/crates/ty/tests/cli/file_selection.rs b/crates/ty/tests/cli/file_selection.rs index 5668e5829d0f0..46f9106c21c21 100644 --- a/crates/ty/tests/cli/file_selection.rs +++ b/crates/ty/tests/cli/file_selection.rs @@ -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([ diff --git a/crates/ty_project/src/metadata/options.rs b/crates/ty_project/src/metadata/options.rs index d83270be901d9..8fb75ab201a6b 100644 --- a/crates/ty_project/src/metadata/options.rs +++ b/crates/ty_project/src/metadata/options.rs @@ -1186,6 +1186,16 @@ impl From 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, diff --git a/crates/ty_project/src/metadata/value.rs b/crates/ty_project/src/metadata/value.rs index 22d940df58c85..c69b5df51efa1 100644 --- a/crates/ty_project/src/metadata/value.rs +++ b/crates/ty_project/src/metadata/value.rs @@ -179,14 +179,13 @@ impl RangedValue { } } -impl Combine for RangedValue { - fn combine(self, _other: Self) -> Self - where - Self: Sized, - { - self +impl Combine for RangedValue +where + T: Combine, +{ + fn combine_with(&mut self, other: Self) { + self.value.combine_with(other.value); } - fn combine_with(&mut self, _other: Self) {} } impl IntoIterator for RangedValue diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index e3b8b8e89e99c..ef9b9565fc10c 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -7488,7 +7488,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),