mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 21:40:51 -05:00
Actually, rename TYP rules to TCH (#2176)
This commit is contained in:
@@ -160,7 +160,7 @@ impl Plugin {
|
||||
Plugin::Flake8Return => RuleCodePrefix::RET.into(),
|
||||
Plugin::Flake8Simplify => RuleCodePrefix::SIM.into(),
|
||||
Plugin::Flake8TidyImports => RuleCodePrefix::TID.into(),
|
||||
Plugin::Flake8TypeChecking => RuleCodePrefix::TYC.into(),
|
||||
Plugin::Flake8TypeChecking => RuleCodePrefix::TCH.into(),
|
||||
Plugin::Flake8UnusedArguments => RuleCodePrefix::ARG.into(),
|
||||
Plugin::Flake8UsePathlib => RuleCodePrefix::PTH.into(),
|
||||
Plugin::McCabe => RuleCodePrefix::C9.into(),
|
||||
|
||||
@@ -429,11 +429,11 @@ ruff_macros::define_rule_mapping!(
|
||||
EXE004 => rules::flake8_executable::rules::ShebangWhitespace,
|
||||
EXE005 => rules::flake8_executable::rules::ShebangNewline,
|
||||
// flake8-type-checking
|
||||
TYC001 => rules::flake8_type_checking::rules::TypingOnlyFirstPartyImport,
|
||||
TYC002 => rules::flake8_type_checking::rules::TypingOnlyThirdPartyImport,
|
||||
TYC003 => rules::flake8_type_checking::rules::TypingOnlyStandardLibraryImport,
|
||||
TYC004 => rules::flake8_type_checking::rules::RuntimeImportInTypeCheckingBlock,
|
||||
TYC005 => rules::flake8_type_checking::rules::EmptyTypeCheckingBlock,
|
||||
TCH001 => rules::flake8_type_checking::rules::TypingOnlyFirstPartyImport,
|
||||
TCH002 => rules::flake8_type_checking::rules::TypingOnlyThirdPartyImport,
|
||||
TCH003 => rules::flake8_type_checking::rules::TypingOnlyStandardLibraryImport,
|
||||
TCH004 => rules::flake8_type_checking::rules::RuntimeImportInTypeCheckingBlock,
|
||||
TCH005 => rules::flake8_type_checking::rules::EmptyTypeCheckingBlock,
|
||||
// tryceratops
|
||||
TRY004 => rules::tryceratops::rules::PreferTypeError,
|
||||
TRY200 => rules::tryceratops::rules::ReraiseNoCause,
|
||||
@@ -584,7 +584,7 @@ pub enum Linter {
|
||||
#[prefix = "EXE"]
|
||||
Flake8Executable,
|
||||
/// [flake8-type-checking](https://pypi.org/project/flake8-type-checking/)
|
||||
#[prefix = "TYC"]
|
||||
#[prefix = "TCH"]
|
||||
Flake8TypeChecking,
|
||||
/// [tryceratops](https://pypi.org/project/tryceratops/1.1.0/)
|
||||
#[prefix = "TRY"]
|
||||
|
||||
@@ -82,7 +82,7 @@ static REDIRECTS: Lazy<HashMap<&'static str, &'static str>> = Lazy::new(|| {
|
||||
("PDV90", "PD90"),
|
||||
("PDV901", "PD901"),
|
||||
// TODO(charlie): Remove by 2023-04-01.
|
||||
("TYP", "TYC"),
|
||||
("TYP001", "TYC001"),
|
||||
("TYP", "TCH"),
|
||||
("TYP001", "TCH001"),
|
||||
])
|
||||
});
|
||||
|
||||
@@ -14,18 +14,18 @@ mod tests {
|
||||
use crate::registry::Rule;
|
||||
use crate::settings;
|
||||
|
||||
#[test_case(Rule::TypingOnlyFirstPartyImport, Path::new("TYC001.py"); "TYC001")]
|
||||
#[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("TYC002.py"); "TYC002")]
|
||||
#[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("TYC003.py"); "TYC003")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TYC004_1.py"); "TYC004_1")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TYC004_2.py"); "TYC004_2")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TYC004_3.py"); "TYC004_3")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TYC004_4.py"); "TYC004_4")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TYC004_5.py"); "TYC004_5")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TYC004_6.py"); "TYC004_6")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TYC004_7.py"); "TYC004_7")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TYC004_8.py"); "TYC004_8")]
|
||||
#[test_case(Rule::EmptyTypeCheckingBlock, Path::new("TYC005.py"); "TYC005")]
|
||||
#[test_case(Rule::TypingOnlyFirstPartyImport, Path::new("TCH001.py"); "TCH001")]
|
||||
#[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("TCH002.py"); "TCH002")]
|
||||
#[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("TCH003.py"); "TCH003")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_1.py"); "TCH004_1")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_2.py"); "TCH004_2")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_3.py"); "TCH004_3")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_4.py"); "TCH004_4")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_5.py"); "TCH004_5")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_6.py"); "TCH004_6")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_7.py"); "TCH004_7")]
|
||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_8.py"); "TCH004_8")]
|
||||
#[test_case(Rule::EmptyTypeCheckingBlock, Path::new("TCH005.py"); "TCH005")]
|
||||
fn rules(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
|
||||
@@ -17,7 +17,7 @@ impl Violation for EmptyTypeCheckingBlock {
|
||||
}
|
||||
}
|
||||
|
||||
/// TYC005
|
||||
/// TCH005
|
||||
pub fn empty_type_checking_block(checker: &mut Checker, test: &Expr, body: &[Stmt]) {
|
||||
if checker.resolve_call_path(test).map_or(false, |call_path| {
|
||||
call_path.as_slice() == ["typing", "TYPE_CHECKING"]
|
||||
|
||||
@@ -22,7 +22,7 @@ impl Violation for RuntimeImportInTypeCheckingBlock {
|
||||
}
|
||||
}
|
||||
|
||||
/// TYC004
|
||||
/// TCH004
|
||||
pub fn runtime_import_in_type_checking_block(
|
||||
binding: &Binding,
|
||||
blocks: &[&Stmt],
|
||||
|
||||
@@ -55,7 +55,7 @@ impl Violation for TypingOnlyStandardLibraryImport {
|
||||
}
|
||||
}
|
||||
|
||||
/// TYC001
|
||||
/// TCH001
|
||||
pub fn typing_only_runtime_import(
|
||||
binding: &Binding,
|
||||
blocks: &[&Stmt],
|
||||
|
||||
Reference in New Issue
Block a user