mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 07:04:53 +00:00
Fix missing combine
call for lint.typing-extensions
setting (#17823)
## Summary Fixes #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.
This commit is contained in:
parent
fa628018b2
commit
fe4051b2e6
2 changed files with 32 additions and 1 deletions
|
@ -5654,3 +5654,34 @@ fn semantic_syntax_errors() -> Result<()> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Regression test for <https://github.com/astral-sh/ruff/issues/17821>.
|
||||||
|
///
|
||||||
|
/// `lint.typing-extensions = false` with Python 3.9 should disable the PYI019 lint because it would
|
||||||
|
/// try to import `Self` from `typing_extensions`
|
||||||
|
#[test]
|
||||||
|
fn combine_typing_extensions_config() {
|
||||||
|
let contents = "
|
||||||
|
from typing import TypeVar
|
||||||
|
T = TypeVar('T')
|
||||||
|
class Foo:
|
||||||
|
def f(self: T) -> T: ...
|
||||||
|
";
|
||||||
|
assert_cmd_snapshot!(
|
||||||
|
Command::new(get_cargo_bin(BIN_NAME))
|
||||||
|
.args(STDIN_BASE_OPTIONS)
|
||||||
|
.args(["--config", "lint.typing-extensions = false"])
|
||||||
|
.arg("--select=PYI019")
|
||||||
|
.arg("--target-version=py39")
|
||||||
|
.arg("-")
|
||||||
|
.pass_stdin(contents),
|
||||||
|
@r"
|
||||||
|
success: true
|
||||||
|
exit_code: 0
|
||||||
|
----- stdout -----
|
||||||
|
All checks passed!
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -1172,7 +1172,7 @@ impl LintConfiguration {
|
||||||
pylint: self.pylint.combine(config.pylint),
|
pylint: self.pylint.combine(config.pylint),
|
||||||
pyupgrade: self.pyupgrade.combine(config.pyupgrade),
|
pyupgrade: self.pyupgrade.combine(config.pyupgrade),
|
||||||
ruff: self.ruff.combine(config.ruff),
|
ruff: self.ruff.combine(config.ruff),
|
||||||
typing_extensions: self.typing_extensions,
|
typing_extensions: self.typing_extensions.or(config.typing_extensions),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue