Skip to content

Commit 9f98cc8

Browse files
committed
[ty] Fix Combine implementation of RangedValue
1 parent 76efc80 commit 9f98cc8

File tree

4 files changed

+92
-8
lines changed

4 files changed

+92
-8
lines changed

crates/ty/tests/cli/file_selection.rs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,81 @@ fn explicit_path_overrides_exclude() -> anyhow::Result<()> {
589589
Ok(())
590590
}
591591

592+
#[test]
593+
fn cli_and_configuration_exclude() -> anyhow::Result<()> {
594+
let case = CliTest::with_files([
595+
(
596+
"src/main.py",
597+
r#"
598+
print(undefined_var) # error: unresolved-reference
599+
"#,
600+
),
601+
(
602+
"tests/generated.py",
603+
r#"
604+
print(dist_undefined_var) # error: unresolved-reference
605+
"#,
606+
),
607+
(
608+
"my_dist/other.py",
609+
r#"
610+
print(other_undefined_var) # error: unresolved-reference
611+
"#,
612+
),
613+
(
614+
"ty.toml",
615+
r#"
616+
[src]
617+
exclude = ["tests/"]
618+
"#,
619+
),
620+
])?;
621+
622+
assert_cmd_snapshot!(case.command(), @r"
623+
success: false
624+
exit_code: 1
625+
----- stdout -----
626+
error[unresolved-reference]: Name `other_undefined_var` used when not defined
627+
--> my_dist/other.py:2:7
628+
|
629+
2 | print(other_undefined_var) # error: unresolved-reference
630+
| ^^^^^^^^^^^^^^^^^^^
631+
|
632+
info: rule `unresolved-reference` is enabled by default
633+
634+
error[unresolved-reference]: Name `undefined_var` used when not defined
635+
--> src/main.py:2:7
636+
|
637+
2 | print(undefined_var) # error: unresolved-reference
638+
| ^^^^^^^^^^^^^
639+
|
640+
info: rule `unresolved-reference` is enabled by default
641+
642+
Found 2 diagnostics
643+
644+
----- stderr -----
645+
");
646+
647+
assert_cmd_snapshot!(case.command().arg("--exclude").arg("my_dist/"), @r"
648+
success: false
649+
exit_code: 1
650+
----- stdout -----
651+
error[unresolved-reference]: Name `undefined_var` used when not defined
652+
--> src/main.py:2:7
653+
|
654+
2 | print(undefined_var) # error: unresolved-reference
655+
| ^^^^^^^^^^^^^
656+
|
657+
info: rule `unresolved-reference` is enabled by default
658+
659+
Found 1 diagnostic
660+
661+
----- stderr -----
662+
");
663+
664+
Ok(())
665+
}
666+
592667
#[test]
593668
fn invalid_include_pattern() -> anyhow::Result<()> {
594669
let case = CliTest::with_files([

crates/ty_project/src/metadata/options.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,16 @@ impl From<OutputFormat> for DiagnosticFormat {
11861186
}
11871187
}
11881188

1189+
impl Combine for OutputFormat {
1190+
#[inline(always)]
1191+
fn combine_with(&mut self, _other: Self) {}
1192+
1193+
#[inline]
1194+
fn combine(self, _other: Self) -> Self {
1195+
self
1196+
}
1197+
}
1198+
11891199
#[derive(
11901200
Debug,
11911201
Default,

crates/ty_project/src/metadata/value.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,13 @@ impl<T> RangedValue<T> {
179179
}
180180
}
181181

182-
impl<T> Combine for RangedValue<T> {
183-
fn combine(self, _other: Self) -> Self
184-
where
185-
Self: Sized,
186-
{
187-
self
182+
impl<T> Combine for RangedValue<T>
183+
where
184+
T: Combine,
185+
{
186+
fn combine_with(&mut self, other: Self) {
187+
self.value.combine_with(other.value);
188188
}
189-
fn combine_with(&mut self, _other: Self) {}
190189
}
191190

192191
impl<T> IntoIterator for RangedValue<T>

crates/ty_python_semantic/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7488,7 +7488,7 @@ impl<'db> VarianceInferable<'db> for Type<'db> {
74887488
| Type::TypeAlias(_) => TypeVarVariance::Bivariant,
74897489
};
74907490

7491-
tracing::debug!(
7491+
tracing::trace!(
74927492
"Result of variance of '{tvar}' in `{ty:?}` is `{v:?}`",
74937493
tvar = typevar.typevar(db).name(db),
74947494
ty = self.display(db),

0 commit comments

Comments
 (0)