Skip to content

Commit fe4051b

Browse files
authored
Fix missing combine call for lint.typing-extensions setting (astral-sh#17823)
## Summary Fixes astral-sh#17821. ## Test Plan New CLI test. This might be overkill for such a simple fix, but it made me feel better to add a test.
1 parent fa62801 commit fe4051b

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

crates/ruff/tests/lint.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5654,3 +5654,34 @@ fn semantic_syntax_errors() -> Result<()> {
56545654

56555655
Ok(())
56565656
}
5657+
5658+
/// Regression test for <https://github.com/astral-sh/ruff/issues/17821>.
5659+
///
5660+
/// `lint.typing-extensions = false` with Python 3.9 should disable the PYI019 lint because it would
5661+
/// try to import `Self` from `typing_extensions`
5662+
#[test]
5663+
fn combine_typing_extensions_config() {
5664+
let contents = "
5665+
from typing import TypeVar
5666+
T = TypeVar('T')
5667+
class Foo:
5668+
def f(self: T) -> T: ...
5669+
";
5670+
assert_cmd_snapshot!(
5671+
Command::new(get_cargo_bin(BIN_NAME))
5672+
.args(STDIN_BASE_OPTIONS)
5673+
.args(["--config", "lint.typing-extensions = false"])
5674+
.arg("--select=PYI019")
5675+
.arg("--target-version=py39")
5676+
.arg("-")
5677+
.pass_stdin(contents),
5678+
@r"
5679+
success: true
5680+
exit_code: 0
5681+
----- stdout -----
5682+
All checks passed!
5683+
5684+
----- stderr -----
5685+
"
5686+
);
5687+
}

crates/ruff_workspace/src/configuration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ impl LintConfiguration {
11721172
pylint: self.pylint.combine(config.pylint),
11731173
pyupgrade: self.pyupgrade.combine(config.pyupgrade),
11741174
ruff: self.ruff.combine(config.ruff),
1175-
typing_extensions: self.typing_extensions,
1175+
typing_extensions: self.typing_extensions.or(config.typing_extensions),
11761176
}
11771177
}
11781178
}

0 commit comments

Comments
 (0)