From 5f715417e03dc9692eac73953f9683768dad20ab Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 29 May 2023 18:23:56 -0400 Subject: [PATCH] Remove redundant test descriptions from `#test_case` macros (#4713) --- crates/ruff/src/rules/airflow/mod.rs | 2 +- crates/ruff/src/rules/eradicate/mod.rs | 2 +- crates/ruff/src/rules/flake8_2020/mod.rs | 20 +- crates/ruff/src/rules/flake8_async/mod.rs | 6 +- crates/ruff/src/rules/flake8_bandit/mod.rs | 56 ++--- .../ruff/src/rules/flake8_blind_except/mod.rs | 2 +- .../ruff/src/rules/flake8_boolean_trap/mod.rs | 6 +- crates/ruff/src/rules/flake8_bugbear/mod.rs | 68 +++--- crates/ruff/src/rules/flake8_builtins/mod.rs | 12 +- crates/ruff/src/rules/flake8_commas/mod.rs | 2 +- .../src/rules/flake8_comprehensions/mod.rs | 38 ++-- crates/ruff/src/rules/flake8_datetimez/mod.rs | 18 +- crates/ruff/src/rules/flake8_debugger/mod.rs | 2 +- crates/ruff/src/rules/flake8_django/mod.rs | 14 +- .../ruff/src/rules/flake8_executable/mod.rs | 26 +-- .../rules/flake8_future_annotations/mod.rs | 24 +- crates/ruff/src/rules/flake8_gettext/mod.rs | 6 +- .../rules/flake8_implicit_str_concat/mod.rs | 12 +- .../src/rules/flake8_logging_format/mod.rs | 28 +-- crates/ruff/src/rules/flake8_no_pep420/mod.rs | 16 +- crates/ruff/src/rules/flake8_pie/mod.rs | 14 +- crates/ruff/src/rules/flake8_print/mod.rs | 4 +- .../ruff/src/rules/flake8_pytest_style/mod.rs | 99 +++++---- crates/ruff/src/rules/flake8_raise/mod.rs | 2 +- crates/ruff/src/rules/flake8_return/mod.rs | 16 +- crates/ruff/src/rules/flake8_self/mod.rs | 2 +- crates/ruff/src/rules/flake8_simplify/mod.rs | 62 +++--- crates/ruff/src/rules/flake8_todos/mod.rs | 14 +- .../src/rules/flake8_type_checking/mod.rs | 72 +++--- .../src/rules/flake8_unused_arguments/mod.rs | 10 +- .../ruff/src/rules/flake8_use_pathlib/mod.rs | 19 +- crates/ruff/src/rules/flynt/mod.rs | 2 +- crates/ruff/src/rules/numpy/mod.rs | 4 +- crates/ruff/src/rules/pandas_vet/mod.rs | 2 +- crates/ruff/src/rules/pep8_naming/mod.rs | 88 +++++--- crates/ruff/src/rules/pydocstyle/mod.rs | 123 ++++++----- crates/ruff/src/rules/pyflakes/mod.rs | 208 +++++++++--------- crates/ruff/src/rules/pygrep_hooks/mod.rs | 16 +- crates/ruff/src/rules/pylint/mod.rs | 143 +++++++----- crates/ruff/src/rules/pyupgrade/mod.rs | 116 +++++----- crates/ruff/src/rules/ruff/mod.rs | 10 +- crates/ruff/src/rules/tryceratops/mod.rs | 20 +- scripts/add_rule.py | 8 +- 43 files changed, 751 insertions(+), 663 deletions(-) diff --git a/crates/ruff/src/rules/airflow/mod.rs b/crates/ruff/src/rules/airflow/mod.rs index e6d6ddf804..12871a42aa 100644 --- a/crates/ruff/src/rules/airflow/mod.rs +++ b/crates/ruff/src/rules/airflow/mod.rs @@ -12,7 +12,7 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::AirflowVariableNameTaskIdMismatch, Path::new("AIR001.py"); "AIR001")] + #[test_case(Rule::AirflowVariableNameTaskIdMismatch, Path::new("AIR001.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/eradicate/mod.rs b/crates/ruff/src/rules/eradicate/mod.rs index 3f26ac808e..a363458154 100644 --- a/crates/ruff/src/rules/eradicate/mod.rs +++ b/crates/ruff/src/rules/eradicate/mod.rs @@ -13,7 +13,7 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::CommentedOutCode, Path::new("ERA001.py"); "ERA001")] + #[test_case(Rule::CommentedOutCode, Path::new("ERA001.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_2020/mod.rs b/crates/ruff/src/rules/flake8_2020/mod.rs index 35b09c2da8..ac20ee0b38 100644 --- a/crates/ruff/src/rules/flake8_2020/mod.rs +++ b/crates/ruff/src/rules/flake8_2020/mod.rs @@ -13,16 +13,16 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::SysVersionSlice3, Path::new("YTT101.py"); "YTT101")] - #[test_case(Rule::SysVersion2, Path::new("YTT102.py"); "YTT102")] - #[test_case(Rule::SysVersionCmpStr3, Path::new("YTT103.py"); "YTT103")] - #[test_case(Rule::SysVersionInfo0Eq3, Path::new("YTT201.py"); "YTT201")] - #[test_case(Rule::SixPY3, Path::new("YTT202.py"); "YTT202")] - #[test_case(Rule::SysVersionInfo1CmpInt, Path::new("YTT203.py"); "YTT203")] - #[test_case(Rule::SysVersionInfoMinorCmpInt, Path::new("YTT204.py"); "YTT204")] - #[test_case(Rule::SysVersion0, Path::new("YTT301.py"); "YTT301")] - #[test_case(Rule::SysVersionCmpStr10, Path::new("YTT302.py"); "YTT302")] - #[test_case(Rule::SysVersionSlice1, Path::new("YTT303.py"); "YTT303")] + #[test_case(Rule::SysVersionSlice3, Path::new("YTT101.py"))] + #[test_case(Rule::SysVersion2, Path::new("YTT102.py"))] + #[test_case(Rule::SysVersionCmpStr3, Path::new("YTT103.py"))] + #[test_case(Rule::SysVersionInfo0Eq3, Path::new("YTT201.py"))] + #[test_case(Rule::SixPY3, Path::new("YTT202.py"))] + #[test_case(Rule::SysVersionInfo1CmpInt, Path::new("YTT203.py"))] + #[test_case(Rule::SysVersionInfoMinorCmpInt, Path::new("YTT204.py"))] + #[test_case(Rule::SysVersion0, Path::new("YTT301.py"))] + #[test_case(Rule::SysVersionCmpStr10, Path::new("YTT302.py"))] + #[test_case(Rule::SysVersionSlice1, Path::new("YTT303.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_async/mod.rs b/crates/ruff/src/rules/flake8_async/mod.rs index 8842526400..7865ddf6b0 100644 --- a/crates/ruff/src/rules/flake8_async/mod.rs +++ b/crates/ruff/src/rules/flake8_async/mod.rs @@ -13,9 +13,9 @@ mod tests { use crate::settings::Settings; use crate::test::test_path; - #[test_case(Rule::BlockingHttpCallInAsyncFunction, Path::new("ASYNC100.py"); "ASYNC100")] - #[test_case(Rule::OpenSleepOrSubprocessInAsyncFunction, Path::new("ASYNC101.py"); "ASYNC101")] - #[test_case(Rule::BlockingOsCallInAsyncFunction, Path::new("ASYNC102.py"); "ASYNC102")] + #[test_case(Rule::BlockingHttpCallInAsyncFunction, Path::new("ASYNC100.py"))] + #[test_case(Rule::OpenSleepOrSubprocessInAsyncFunction, Path::new("ASYNC101.py"))] + #[test_case(Rule::BlockingOsCallInAsyncFunction, Path::new("ASYNC102.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_bandit/mod.rs b/crates/ruff/src/rules/flake8_bandit/mod.rs index fc7e2b6e28..d75bf471dd 100644 --- a/crates/ruff/src/rules/flake8_bandit/mod.rs +++ b/crates/ruff/src/rules/flake8_bandit/mod.rs @@ -15,34 +15,34 @@ mod tests { use crate::settings::Settings; use crate::test::test_path; - #[test_case(Rule::Assert, Path::new("S101.py"); "S101")] - #[test_case(Rule::BadFilePermissions, Path::new("S103.py"); "S103")] - #[test_case(Rule::CallWithShellEqualsTrue, Path::new("S604.py"); "S604")] - #[test_case(Rule::ExecBuiltin, Path::new("S102.py"); "S102")] - #[test_case(Rule::HardcodedBindAllInterfaces, Path::new("S104.py"); "S104")] - #[test_case(Rule::HardcodedPasswordDefault, Path::new("S107.py"); "S107")] - #[test_case(Rule::HardcodedPasswordFuncArg, Path::new("S106.py"); "S106")] - #[test_case(Rule::HardcodedPasswordString, Path::new("S105.py"); "S105")] - #[test_case(Rule::HardcodedSQLExpression, Path::new("S608.py"); "S608")] - #[test_case(Rule::HardcodedTempFile, Path::new("S108.py"); "S108")] - #[test_case(Rule::HashlibInsecureHashFunction, Path::new("S324.py"); "S324")] - #[test_case(Rule::Jinja2AutoescapeFalse, Path::new("S701.py"); "S701")] - #[test_case(Rule::LoggingConfigInsecureListen, Path::new("S612.py"); "S612")] - #[test_case(Rule::RequestWithNoCertValidation, Path::new("S501.py"); "S501")] - #[test_case(Rule::RequestWithoutTimeout, Path::new("S113.py"); "S113")] - #[test_case(Rule::SnmpInsecureVersion, Path::new("S508.py"); "S508")] - #[test_case(Rule::SnmpWeakCryptography, Path::new("S509.py"); "S509")] - #[test_case(Rule::StartProcessWithAShell, Path::new("S605.py"); "S605")] - #[test_case(Rule::StartProcessWithNoShell, Path::new("S606.py"); "S606")] - #[test_case(Rule::StartProcessWithPartialPath, Path::new("S607.py"); "S607")] - #[test_case(Rule::SubprocessPopenWithShellEqualsTrue, Path::new("S602.py"); "S602")] - #[test_case(Rule::SubprocessWithoutShellEqualsTrue, Path::new("S603.py"); "S603")] - #[test_case(Rule::SuspiciousPickleUsage, Path::new("S301.py"); "S301")] - #[test_case(Rule::SuspiciousTelnetUsage, Path::new("S312.py"); "S312")] - #[test_case(Rule::TryExceptContinue, Path::new("S112.py"); "S112")] - #[test_case(Rule::TryExceptPass, Path::new("S110.py"); "S110")] - #[test_case(Rule::UnsafeYAMLLoad, Path::new("S506.py"); "S506")] - #[test_case(Rule::ParamikoCall, Path::new("S601.py"); "S601")] + #[test_case(Rule::Assert, Path::new("S101.py"))] + #[test_case(Rule::BadFilePermissions, Path::new("S103.py"))] + #[test_case(Rule::CallWithShellEqualsTrue, Path::new("S604.py"))] + #[test_case(Rule::ExecBuiltin, Path::new("S102.py"))] + #[test_case(Rule::HardcodedBindAllInterfaces, Path::new("S104.py"))] + #[test_case(Rule::HardcodedPasswordDefault, Path::new("S107.py"))] + #[test_case(Rule::HardcodedPasswordFuncArg, Path::new("S106.py"))] + #[test_case(Rule::HardcodedPasswordString, Path::new("S105.py"))] + #[test_case(Rule::HardcodedSQLExpression, Path::new("S608.py"))] + #[test_case(Rule::HardcodedTempFile, Path::new("S108.py"))] + #[test_case(Rule::HashlibInsecureHashFunction, Path::new("S324.py"))] + #[test_case(Rule::Jinja2AutoescapeFalse, Path::new("S701.py"))] + #[test_case(Rule::LoggingConfigInsecureListen, Path::new("S612.py"))] + #[test_case(Rule::RequestWithNoCertValidation, Path::new("S501.py"))] + #[test_case(Rule::RequestWithoutTimeout, Path::new("S113.py"))] + #[test_case(Rule::SnmpInsecureVersion, Path::new("S508.py"))] + #[test_case(Rule::SnmpWeakCryptography, Path::new("S509.py"))] + #[test_case(Rule::StartProcessWithAShell, Path::new("S605.py"))] + #[test_case(Rule::StartProcessWithNoShell, Path::new("S606.py"))] + #[test_case(Rule::StartProcessWithPartialPath, Path::new("S607.py"))] + #[test_case(Rule::SubprocessPopenWithShellEqualsTrue, Path::new("S602.py"))] + #[test_case(Rule::SubprocessWithoutShellEqualsTrue, Path::new("S603.py"))] + #[test_case(Rule::SuspiciousPickleUsage, Path::new("S301.py"))] + #[test_case(Rule::SuspiciousTelnetUsage, Path::new("S312.py"))] + #[test_case(Rule::TryExceptContinue, Path::new("S112.py"))] + #[test_case(Rule::TryExceptPass, Path::new("S110.py"))] + #[test_case(Rule::UnsafeYAMLLoad, Path::new("S506.py"))] + #[test_case(Rule::ParamikoCall, Path::new("S601.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_blind_except/mod.rs b/crates/ruff/src/rules/flake8_blind_except/mod.rs index 1ade0f4092..ce2611ffaa 100644 --- a/crates/ruff/src/rules/flake8_blind_except/mod.rs +++ b/crates/ruff/src/rules/flake8_blind_except/mod.rs @@ -12,7 +12,7 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::BlindExcept, Path::new("BLE.py"); "BLE001")] + #[test_case(Rule::BlindExcept, Path::new("BLE.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_boolean_trap/mod.rs b/crates/ruff/src/rules/flake8_boolean_trap/mod.rs index 1e86c51cbf..ab0d6f8741 100644 --- a/crates/ruff/src/rules/flake8_boolean_trap/mod.rs +++ b/crates/ruff/src/rules/flake8_boolean_trap/mod.rs @@ -13,9 +13,9 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::BooleanPositionalArgInFunctionDefinition, Path::new("FBT.py"); "FBT001")] - #[test_case(Rule::BooleanDefaultValueInFunctionDefinition, Path::new("FBT.py"); "FBT002")] - #[test_case(Rule::BooleanPositionalValueInFunctionCall, Path::new("FBT.py"); "FBT003")] + #[test_case(Rule::BooleanPositionalArgInFunctionDefinition, Path::new("FBT.py"))] + #[test_case(Rule::BooleanDefaultValueInFunctionDefinition, Path::new("FBT.py"))] + #[test_case(Rule::BooleanPositionalValueInFunctionCall, Path::new("FBT.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_bugbear/mod.rs b/crates/ruff/src/rules/flake8_bugbear/mod.rs index 386b591a8f..896b977adf 100644 --- a/crates/ruff/src/rules/flake8_bugbear/mod.rs +++ b/crates/ruff/src/rules/flake8_bugbear/mod.rs @@ -14,40 +14,40 @@ mod tests { use crate::settings::Settings; use crate::test::test_path; - #[test_case(Rule::UnaryPrefixIncrement, Path::new("B002.py"); "B002")] - #[test_case(Rule::AssignmentToOsEnviron, Path::new("B003.py"); "B003")] - #[test_case(Rule::UnreliableCallableCheck, Path::new("B004.py"); "B004")] - #[test_case(Rule::StripWithMultiCharacters, Path::new("B005.py"); "B005")] - #[test_case(Rule::MutableArgumentDefault, Path::new("B006_B008.py"); "B006")] - #[test_case(Rule::UnusedLoopControlVariable, Path::new("B007.py"); "B007")] - #[test_case(Rule::FunctionCallInDefaultArgument, Path::new("B006_B008.py"); "B008")] - #[test_case(Rule::GetAttrWithConstant, Path::new("B009_B010.py"); "B009")] - #[test_case(Rule::SetAttrWithConstant, Path::new("B009_B010.py"); "B010")] - #[test_case(Rule::AssertFalse, Path::new("B011.py"); "B011")] - #[test_case(Rule::JumpStatementInFinally, Path::new("B012.py"); "B012")] - #[test_case(Rule::RedundantTupleInExceptionHandler, Path::new("B013.py"); "B013")] - #[test_case(Rule::DuplicateHandlerException, Path::new("B014.py"); "B014")] - #[test_case(Rule::UselessComparison, Path::new("B015.py"); "B015")] - #[test_case(Rule::CannotRaiseLiteral, Path::new("B016.py"); "B016")] - #[test_case(Rule::AssertRaisesException, Path::new("B017.py"); "B017")] - #[test_case(Rule::UselessExpression, Path::new("B018.py"); "B018")] - #[test_case(Rule::CachedInstanceMethod, Path::new("B019.py"); "B019")] - #[test_case(Rule::LoopVariableOverridesIterator, Path::new("B020.py"); "B020")] - #[test_case(Rule::FStringDocstring, Path::new("B021.py"); "B021")] - #[test_case(Rule::UselessContextlibSuppress, Path::new("B022.py"); "B022")] - #[test_case(Rule::FunctionUsesLoopVariable, Path::new("B023.py"); "B023")] - #[test_case(Rule::AbstractBaseClassWithoutAbstractMethod, Path::new("B024.py"); "B024")] - #[test_case(Rule::DuplicateTryBlockException, Path::new("B025.py"); "B025")] - #[test_case(Rule::StarArgUnpackingAfterKeywordArg, Path::new("B026.py"); "B026")] - #[test_case(Rule::EmptyMethodWithoutAbstractDecorator, Path::new("B027.py"); "B027")] - #[test_case(Rule::EmptyMethodWithoutAbstractDecorator, Path::new("B027.pyi"); "B027_pyi")] - #[test_case(Rule::NoExplicitStacklevel, Path::new("B028.py"); "B028")] - #[test_case(Rule::ExceptWithEmptyTuple, Path::new("B029.py"); "B029")] - #[test_case(Rule::ExceptWithNonExceptionClasses, Path::new("B030.py"); "B030")] - #[test_case(Rule::ReuseOfGroupbyGenerator, Path::new("B031.py"); "B031")] - #[test_case(Rule::UnintentionalTypeAnnotation, Path::new("B032.py"); "B032")] - #[test_case(Rule::RaiseWithoutFromInsideExcept, Path::new("B904.py"); "B904")] - #[test_case(Rule::ZipWithoutExplicitStrict, Path::new("B905.py"); "B905")] + #[test_case(Rule::UnaryPrefixIncrement, Path::new("B002.py"))] + #[test_case(Rule::AssignmentToOsEnviron, Path::new("B003.py"))] + #[test_case(Rule::UnreliableCallableCheck, Path::new("B004.py"))] + #[test_case(Rule::StripWithMultiCharacters, Path::new("B005.py"))] + #[test_case(Rule::MutableArgumentDefault, Path::new("B006_B008.py"))] + #[test_case(Rule::UnusedLoopControlVariable, Path::new("B007.py"))] + #[test_case(Rule::FunctionCallInDefaultArgument, Path::new("B006_B008.py"))] + #[test_case(Rule::GetAttrWithConstant, Path::new("B009_B010.py"))] + #[test_case(Rule::SetAttrWithConstant, Path::new("B009_B010.py"))] + #[test_case(Rule::AssertFalse, Path::new("B011.py"))] + #[test_case(Rule::JumpStatementInFinally, Path::new("B012.py"))] + #[test_case(Rule::RedundantTupleInExceptionHandler, Path::new("B013.py"))] + #[test_case(Rule::DuplicateHandlerException, Path::new("B014.py"))] + #[test_case(Rule::UselessComparison, Path::new("B015.py"))] + #[test_case(Rule::CannotRaiseLiteral, Path::new("B016.py"))] + #[test_case(Rule::AssertRaisesException, Path::new("B017.py"))] + #[test_case(Rule::UselessExpression, Path::new("B018.py"))] + #[test_case(Rule::CachedInstanceMethod, Path::new("B019.py"))] + #[test_case(Rule::LoopVariableOverridesIterator, Path::new("B020.py"))] + #[test_case(Rule::FStringDocstring, Path::new("B021.py"))] + #[test_case(Rule::UselessContextlibSuppress, Path::new("B022.py"))] + #[test_case(Rule::FunctionUsesLoopVariable, Path::new("B023.py"))] + #[test_case(Rule::AbstractBaseClassWithoutAbstractMethod, Path::new("B024.py"))] + #[test_case(Rule::DuplicateTryBlockException, Path::new("B025.py"))] + #[test_case(Rule::StarArgUnpackingAfterKeywordArg, Path::new("B026.py"))] + #[test_case(Rule::EmptyMethodWithoutAbstractDecorator, Path::new("B027.py"))] + #[test_case(Rule::EmptyMethodWithoutAbstractDecorator, Path::new("B027.pyi"))] + #[test_case(Rule::NoExplicitStacklevel, Path::new("B028.py"))] + #[test_case(Rule::ExceptWithEmptyTuple, Path::new("B029.py"))] + #[test_case(Rule::ExceptWithNonExceptionClasses, Path::new("B030.py"))] + #[test_case(Rule::ReuseOfGroupbyGenerator, Path::new("B031.py"))] + #[test_case(Rule::UnintentionalTypeAnnotation, Path::new("B032.py"))] + #[test_case(Rule::RaiseWithoutFromInsideExcept, Path::new("B904.py"))] + #[test_case(Rule::ZipWithoutExplicitStrict, Path::new("B905.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_builtins/mod.rs b/crates/ruff/src/rules/flake8_builtins/mod.rs index 58aea5fba4..9321db78d7 100644 --- a/crates/ruff/src/rules/flake8_builtins/mod.rs +++ b/crates/ruff/src/rules/flake8_builtins/mod.rs @@ -15,9 +15,9 @@ mod tests { use crate::settings::Settings; use crate::test::test_path; - #[test_case(Rule::BuiltinVariableShadowing, Path::new("A001.py"); "A001")] - #[test_case(Rule::BuiltinArgumentShadowing, Path::new("A002.py"); "A002")] - #[test_case(Rule::BuiltinAttributeShadowing, Path::new("A003.py"); "A003")] + #[test_case(Rule::BuiltinVariableShadowing, Path::new("A001.py"))] + #[test_case(Rule::BuiltinArgumentShadowing, Path::new("A002.py"))] + #[test_case(Rule::BuiltinAttributeShadowing, Path::new("A003.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( @@ -28,9 +28,9 @@ mod tests { Ok(()) } - #[test_case(Rule::BuiltinVariableShadowing, Path::new("A001.py"); "A001")] - #[test_case(Rule::BuiltinArgumentShadowing, Path::new("A002.py"); "A002")] - #[test_case(Rule::BuiltinAttributeShadowing, Path::new("A003.py"); "A003")] + #[test_case(Rule::BuiltinVariableShadowing, Path::new("A001.py"))] + #[test_case(Rule::BuiltinArgumentShadowing, Path::new("A002.py"))] + #[test_case(Rule::BuiltinAttributeShadowing, Path::new("A003.py"))] fn builtins_ignorelist(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!( "{}_{}_builtins_ignorelist", diff --git a/crates/ruff/src/rules/flake8_commas/mod.rs b/crates/ruff/src/rules/flake8_commas/mod.rs index 675c70a8cc..d08f8fc8ee 100644 --- a/crates/ruff/src/rules/flake8_commas/mod.rs +++ b/crates/ruff/src/rules/flake8_commas/mod.rs @@ -12,7 +12,7 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Path::new("COM81.py"); "COM81")] + #[test_case(Path::new("COM81.py"))] fn rules(path: &Path) -> Result<()> { let snapshot = path.to_string_lossy().into_owned(); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_comprehensions/mod.rs b/crates/ruff/src/rules/flake8_comprehensions/mod.rs index 9806e41659..279b504280 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/mod.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/mod.rs @@ -15,24 +15,24 @@ mod tests { use crate::settings::Settings; use crate::test::test_path; - #[test_case(Rule::UnnecessaryCallAroundSorted, Path::new("C413.py"); "C413")] - #[test_case(Rule::UnnecessaryCollectionCall, Path::new("C408.py"); "C408")] - #[test_case(Rule::UnnecessaryComprehension, Path::new("C416.py"); "C416")] - #[test_case(Rule::UnnecessaryComprehensionAnyAll, Path::new("C419.py"); "C419")] - #[test_case(Rule::UnnecessaryDoubleCastOrProcess, Path::new("C414.py"); "C414")] - #[test_case(Rule::UnnecessaryGeneratorDict, Path::new("C402.py"); "C402")] - #[test_case(Rule::UnnecessaryGeneratorList, Path::new("C400.py"); "C400")] - #[test_case(Rule::UnnecessaryGeneratorSet, Path::new("C401.py"); "C401")] - #[test_case(Rule::UnnecessaryListCall, Path::new("C411.py"); "C411")] - #[test_case(Rule::UnnecessaryListComprehensionDict, Path::new("C404.py"); "C404")] - #[test_case(Rule::UnnecessaryListComprehensionSet, Path::new("C403.py"); "C403")] - #[test_case(Rule::UnnecessaryLiteralDict, Path::new("C406.py"); "C406")] - #[test_case(Rule::UnnecessaryLiteralSet, Path::new("C405.py"); "C405")] - #[test_case(Rule::UnnecessaryLiteralWithinDictCall, Path::new("C418.py"); "C418")] - #[test_case(Rule::UnnecessaryLiteralWithinListCall, Path::new("C410.py"); "C410")] - #[test_case(Rule::UnnecessaryLiteralWithinTupleCall, Path::new("C409.py"); "C409")] - #[test_case(Rule::UnnecessaryMap, Path::new("C417.py"); "C417")] - #[test_case(Rule::UnnecessarySubscriptReversal, Path::new("C415.py"); "C415")] + #[test_case(Rule::UnnecessaryCallAroundSorted, Path::new("C413.py"))] + #[test_case(Rule::UnnecessaryCollectionCall, Path::new("C408.py"))] + #[test_case(Rule::UnnecessaryComprehension, Path::new("C416.py"))] + #[test_case(Rule::UnnecessaryComprehensionAnyAll, Path::new("C419.py"))] + #[test_case(Rule::UnnecessaryDoubleCastOrProcess, Path::new("C414.py"))] + #[test_case(Rule::UnnecessaryGeneratorDict, Path::new("C402.py"))] + #[test_case(Rule::UnnecessaryGeneratorList, Path::new("C400.py"))] + #[test_case(Rule::UnnecessaryGeneratorSet, Path::new("C401.py"))] + #[test_case(Rule::UnnecessaryListCall, Path::new("C411.py"))] + #[test_case(Rule::UnnecessaryListComprehensionDict, Path::new("C404.py"))] + #[test_case(Rule::UnnecessaryListComprehensionSet, Path::new("C403.py"))] + #[test_case(Rule::UnnecessaryLiteralDict, Path::new("C406.py"))] + #[test_case(Rule::UnnecessaryLiteralSet, Path::new("C405.py"))] + #[test_case(Rule::UnnecessaryLiteralWithinDictCall, Path::new("C418.py"))] + #[test_case(Rule::UnnecessaryLiteralWithinListCall, Path::new("C410.py"))] + #[test_case(Rule::UnnecessaryLiteralWithinTupleCall, Path::new("C409.py"))] + #[test_case(Rule::UnnecessaryMap, Path::new("C417.py"))] + #[test_case(Rule::UnnecessarySubscriptReversal, Path::new("C415.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( @@ -43,7 +43,7 @@ mod tests { Ok(()) } - #[test_case(Rule::UnnecessaryCollectionCall, Path::new("C408.py"); "C408")] + #[test_case(Rule::UnnecessaryCollectionCall, Path::new("C408.py"))] fn allow_dict_calls_with_keyword_arguments(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!( "{}_{}_allow_dict_calls_with_keyword_arguments", diff --git a/crates/ruff/src/rules/flake8_datetimez/mod.rs b/crates/ruff/src/rules/flake8_datetimez/mod.rs index b4d19816da..d8af5d3691 100644 --- a/crates/ruff/src/rules/flake8_datetimez/mod.rs +++ b/crates/ruff/src/rules/flake8_datetimez/mod.rs @@ -12,15 +12,15 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::CallDatetimeWithoutTzinfo, Path::new("DTZ001.py"); "DTZ001")] - #[test_case(Rule::CallDatetimeToday, Path::new("DTZ002.py"); "DTZ002")] - #[test_case(Rule::CallDatetimeUtcnow, Path::new("DTZ003.py"); "DTZ003")] - #[test_case(Rule::CallDatetimeUtcfromtimestamp, Path::new("DTZ004.py"); "DTZ004")] - #[test_case(Rule::CallDatetimeNowWithoutTzinfo, Path::new("DTZ005.py"); "DTZ005")] - #[test_case(Rule::CallDatetimeFromtimestamp, Path::new("DTZ006.py"); "DTZ006")] - #[test_case(Rule::CallDatetimeStrptimeWithoutZone, Path::new("DTZ007.py"); "DTZ007")] - #[test_case(Rule::CallDateToday, Path::new("DTZ011.py"); "DTZ011")] - #[test_case(Rule::CallDateFromtimestamp, Path::new("DTZ012.py"); "DTZ012")] + #[test_case(Rule::CallDatetimeWithoutTzinfo, Path::new("DTZ001.py"))] + #[test_case(Rule::CallDatetimeToday, Path::new("DTZ002.py"))] + #[test_case(Rule::CallDatetimeUtcnow, Path::new("DTZ003.py"))] + #[test_case(Rule::CallDatetimeUtcfromtimestamp, Path::new("DTZ004.py"))] + #[test_case(Rule::CallDatetimeNowWithoutTzinfo, Path::new("DTZ005.py"))] + #[test_case(Rule::CallDatetimeFromtimestamp, Path::new("DTZ006.py"))] + #[test_case(Rule::CallDatetimeStrptimeWithoutZone, Path::new("DTZ007.py"))] + #[test_case(Rule::CallDateToday, Path::new("DTZ011.py"))] + #[test_case(Rule::CallDateFromtimestamp, Path::new("DTZ012.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_debugger/mod.rs b/crates/ruff/src/rules/flake8_debugger/mod.rs index 29a40913ca..51181d43c3 100644 --- a/crates/ruff/src/rules/flake8_debugger/mod.rs +++ b/crates/ruff/src/rules/flake8_debugger/mod.rs @@ -13,7 +13,7 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::Debugger, Path::new("T100.py"); "T100")] + #[test_case(Rule::Debugger, Path::new("T100.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_django/mod.rs b/crates/ruff/src/rules/flake8_django/mod.rs index ec6ad0f098..5917392746 100644 --- a/crates/ruff/src/rules/flake8_django/mod.rs +++ b/crates/ruff/src/rules/flake8_django/mod.rs @@ -12,13 +12,13 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::DjangoNullableModelStringField, Path::new("DJ001.py"); "DJ001")] - #[test_case(Rule::DjangoLocalsInRenderFunction, Path::new("DJ003.py"); "DJ003")] - #[test_case(Rule::DjangoExcludeWithModelForm, Path::new("DJ006.py"); "DJ006")] - #[test_case(Rule::DjangoAllWithModelForm, Path::new("DJ007.py"); "DJ007")] - #[test_case(Rule::DjangoModelWithoutDunderStr, Path::new("DJ008.py"); "DJ008")] - #[test_case(Rule::DjangoUnorderedBodyContentInModel, Path::new("DJ012.py"); "DJ012")] - #[test_case(Rule::DjangoNonLeadingReceiverDecorator, Path::new("DJ013.py"); "DJ013")] + #[test_case(Rule::DjangoNullableModelStringField, Path::new("DJ001.py"))] + #[test_case(Rule::DjangoLocalsInRenderFunction, Path::new("DJ003.py"))] + #[test_case(Rule::DjangoExcludeWithModelForm, Path::new("DJ006.py"))] + #[test_case(Rule::DjangoAllWithModelForm, Path::new("DJ007.py"))] + #[test_case(Rule::DjangoModelWithoutDunderStr, Path::new("DJ008.py"))] + #[test_case(Rule::DjangoUnorderedBodyContentInModel, Path::new("DJ012.py"))] + #[test_case(Rule::DjangoNonLeadingReceiverDecorator, Path::new("DJ013.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_executable/mod.rs b/crates/ruff/src/rules/flake8_executable/mod.rs index a38ffbac24..a1bab8efe2 100644 --- a/crates/ruff/src/rules/flake8_executable/mod.rs +++ b/crates/ruff/src/rules/flake8_executable/mod.rs @@ -14,19 +14,19 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Path::new("EXE001_1.py"); "EXE001_1")] - #[test_case(Path::new("EXE001_2.py"); "EXE001_2")] - #[test_case(Path::new("EXE001_3.py"); "EXE001_3")] - #[test_case(Path::new("EXE002_1.py"); "EXE002_1")] - #[test_case(Path::new("EXE002_2.py"); "EXE002_2")] - #[test_case(Path::new("EXE002_3.py"); "EXE002_3")] - #[test_case(Path::new("EXE003.py"); "EXE003")] - #[test_case(Path::new("EXE004_1.py"); "EXE004_1")] - #[test_case(Path::new("EXE004_2.py"); "EXE004_2")] - #[test_case(Path::new("EXE004_3.py"); "EXE004_3")] - #[test_case(Path::new("EXE005_1.py"); "EXE005_1")] - #[test_case(Path::new("EXE005_2.py"); "EXE005_2")] - #[test_case(Path::new("EXE005_3.py"); "EXE005_3")] + #[test_case(Path::new("EXE001_1.py"))] + #[test_case(Path::new("EXE001_2.py"))] + #[test_case(Path::new("EXE001_3.py"))] + #[test_case(Path::new("EXE002_1.py"))] + #[test_case(Path::new("EXE002_2.py"))] + #[test_case(Path::new("EXE002_3.py"))] + #[test_case(Path::new("EXE003.py"))] + #[test_case(Path::new("EXE004_1.py"))] + #[test_case(Path::new("EXE004_2.py"))] + #[test_case(Path::new("EXE004_3.py"))] + #[test_case(Path::new("EXE005_1.py"))] + #[test_case(Path::new("EXE005_2.py"))] + #[test_case(Path::new("EXE005_3.py"))] fn rules(path: &Path) -> Result<()> { let snapshot = path.to_string_lossy().into_owned(); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_future_annotations/mod.rs b/crates/ruff/src/rules/flake8_future_annotations/mod.rs index 49d6ca57ab..fe5cb20ed6 100644 --- a/crates/ruff/src/rules/flake8_future_annotations/mod.rs +++ b/crates/ruff/src/rules/flake8_future_annotations/mod.rs @@ -13,18 +13,18 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Path::new("edge_case.py"); "edge_case")] - #[test_case(Path::new("from_typing_import.py"); "from_typing_import")] - #[test_case(Path::new("from_typing_import_many.py"); "from_typing_import_many")] - #[test_case(Path::new("import_typing.py"); "import_typing")] - #[test_case(Path::new("import_typing_as.py"); "import_typing_as")] - #[test_case(Path::new("no_future_import_uses_lowercase.py"); "no_future_import_uses_lowercase")] - #[test_case(Path::new("no_future_import_uses_union.py"); "no_future_import_uses_union")] - #[test_case(Path::new("no_future_import_uses_union_inner.py"); "no_future_import_uses_union_inner")] - #[test_case(Path::new("ok_no_types.py"); "ok_no_types")] - #[test_case(Path::new("ok_non_simplifiable_types.py"); "ok_non_simplifiable_types")] - #[test_case(Path::new("ok_uses_future.py"); "ok_uses_future")] - #[test_case(Path::new("ok_variable_name.py"); "ok_variable_name")] + #[test_case(Path::new("edge_case.py"))] + #[test_case(Path::new("from_typing_import.py"))] + #[test_case(Path::new("from_typing_import_many.py"))] + #[test_case(Path::new("import_typing.py"))] + #[test_case(Path::new("import_typing_as.py"))] + #[test_case(Path::new("no_future_import_uses_lowercase.py"))] + #[test_case(Path::new("no_future_import_uses_union.py"))] + #[test_case(Path::new("no_future_import_uses_union_inner.py"))] + #[test_case(Path::new("ok_no_types.py"))] + #[test_case(Path::new("ok_non_simplifiable_types.py"))] + #[test_case(Path::new("ok_uses_future.py"))] + #[test_case(Path::new("ok_variable_name.py"))] fn rules(path: &Path) -> Result<()> { let snapshot = path.to_string_lossy().into_owned(); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_gettext/mod.rs b/crates/ruff/src/rules/flake8_gettext/mod.rs index f7d7145107..d9da7fad86 100644 --- a/crates/ruff/src/rules/flake8_gettext/mod.rs +++ b/crates/ruff/src/rules/flake8_gettext/mod.rs @@ -13,9 +13,9 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::FStringInGetTextFuncCall,Path::new("INT001.py"); "INT001")] - #[test_case(Rule::FormatInGetTextFuncCall, Path::new("INT002.py"); "INT002")] - #[test_case(Rule::PrintfInGetTextFuncCall, Path::new("INT003.py"); "INT003")] + #[test_case(Rule::FStringInGetTextFuncCall, Path::new("INT001.py"))] + #[test_case(Rule::FormatInGetTextFuncCall, Path::new("INT002.py"))] + #[test_case(Rule::PrintfInGetTextFuncCall, Path::new("INT003.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/mod.rs b/crates/ruff/src/rules/flake8_implicit_str_concat/mod.rs index d5ddd4b37d..898b3689af 100644 --- a/crates/ruff/src/rules/flake8_implicit_str_concat/mod.rs +++ b/crates/ruff/src/rules/flake8_implicit_str_concat/mod.rs @@ -13,9 +13,9 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::SingleLineImplicitStringConcatenation, Path::new("ISC.py"); "ISC001")] - #[test_case(Rule::MultiLineImplicitStringConcatenation, Path::new("ISC.py"); "ISC002")] - #[test_case(Rule::ExplicitStringConcatenation, Path::new("ISC.py"); "ISC003")] + #[test_case(Rule::SingleLineImplicitStringConcatenation, Path::new("ISC.py"))] + #[test_case(Rule::MultiLineImplicitStringConcatenation, Path::new("ISC.py"))] + #[test_case(Rule::ExplicitStringConcatenation, Path::new("ISC.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( @@ -26,9 +26,9 @@ mod tests { Ok(()) } - #[test_case(Rule::SingleLineImplicitStringConcatenation, Path::new("ISC.py"); "ISC001")] - #[test_case(Rule::MultiLineImplicitStringConcatenation, Path::new("ISC.py"); "ISC002")] - #[test_case(Rule::ExplicitStringConcatenation, Path::new("ISC.py"); "ISC003")] + #[test_case(Rule::SingleLineImplicitStringConcatenation, Path::new("ISC.py"))] + #[test_case(Rule::MultiLineImplicitStringConcatenation, Path::new("ISC.py"))] + #[test_case(Rule::ExplicitStringConcatenation, Path::new("ISC.py"))] fn multiline(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!( "multiline_{}_{}", diff --git a/crates/ruff/src/rules/flake8_logging_format/mod.rs b/crates/ruff/src/rules/flake8_logging_format/mod.rs index 653b8377a5..c76235febe 100644 --- a/crates/ruff/src/rules/flake8_logging_format/mod.rs +++ b/crates/ruff/src/rules/flake8_logging_format/mod.rs @@ -13,20 +13,20 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Path::new("G_argparse_parser_error_ok.py"); "G_argparse_parser_error_ok")] - #[test_case(Path::new("G_extra_ok.py"); "G_extra_ok")] - #[test_case(Path::new("G_extra_str_format_ok.py"); "G_extra_str_format_ok")] - #[test_case(Path::new("G_simple_ok.py"); "G_simple_ok")] - #[test_case(Path::new("G_warnings_ok.py"); "G_warnings_ok")] - #[test_case(Path::new("G001.py"); "G001")] - #[test_case(Path::new("G002.py"); "G002")] - #[test_case(Path::new("G003.py"); "G003")] - #[test_case(Path::new("G004.py"); "G004")] - #[test_case(Path::new("G010.py"); "G010")] - #[test_case(Path::new("G101_1.py"); "G101_1")] - #[test_case(Path::new("G101_2.py"); "G101_2")] - #[test_case(Path::new("G201.py"); "G201")] - #[test_case(Path::new("G202.py"); "G202")] + #[test_case(Path::new("G_argparse_parser_error_ok.py"))] + #[test_case(Path::new("G_extra_ok.py"))] + #[test_case(Path::new("G_extra_str_format_ok.py"))] + #[test_case(Path::new("G_simple_ok.py"))] + #[test_case(Path::new("G_warnings_ok.py"))] + #[test_case(Path::new("G001.py"))] + #[test_case(Path::new("G002.py"))] + #[test_case(Path::new("G003.py"))] + #[test_case(Path::new("G004.py"))] + #[test_case(Path::new("G010.py"))] + #[test_case(Path::new("G101_1.py"))] + #[test_case(Path::new("G101_2.py"))] + #[test_case(Path::new("G201.py"))] + #[test_case(Path::new("G202.py"))] fn rules(path: &Path) -> Result<()> { let snapshot = path.to_string_lossy().into_owned(); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_no_pep420/mod.rs b/crates/ruff/src/rules/flake8_no_pep420/mod.rs index c6dbdbe605..afb27c3615 100644 --- a/crates/ruff/src/rules/flake8_no_pep420/mod.rs +++ b/crates/ruff/src/rules/flake8_no_pep420/mod.rs @@ -13,14 +13,14 @@ mod tests { use crate::settings::Settings; use crate::test::{test_path, test_resource_path}; - #[test_case(Path::new("test_pass_init"), Path::new("example.py"); "INP001_0")] - #[test_case(Path::new("test_fail_empty"), Path::new("example.py"); "INP001_1")] - #[test_case(Path::new("test_fail_nonempty"), Path::new("example.py"); "INP001_2")] - #[test_case(Path::new("test_fail_shebang"), Path::new("example.py"); "INP001_3")] - #[test_case(Path::new("test_ignored"), Path::new("example.py"); "INP001_4")] - #[test_case(Path::new("test_pass_namespace_package"), Path::new("example.py"); "INP001_5")] - #[test_case(Path::new("test_pass_pyi"), Path::new("example.pyi"); "INP001_6")] - #[test_case(Path::new("test_pass_script"), Path::new("script"); "INP001_7")] + #[test_case(Path::new("test_pass_init"), Path::new("example.py"))] + #[test_case(Path::new("test_fail_empty"), Path::new("example.py"))] + #[test_case(Path::new("test_fail_nonempty"), Path::new("example.py"))] + #[test_case(Path::new("test_fail_shebang"), Path::new("example.py"))] + #[test_case(Path::new("test_ignored"), Path::new("example.py"))] + #[test_case(Path::new("test_pass_namespace_package"), Path::new("example.py"))] + #[test_case(Path::new("test_pass_pyi"), Path::new("example.pyi"))] + #[test_case(Path::new("test_pass_script"), Path::new("script"))] fn test_flake8_no_pep420(path: &Path, filename: &Path) -> Result<()> { let snapshot = format!("{}", path.to_string_lossy()); let p = PathBuf::from(format!( diff --git a/crates/ruff/src/rules/flake8_pie/mod.rs b/crates/ruff/src/rules/flake8_pie/mod.rs index ed9b8730ab..a1cfb8349c 100644 --- a/crates/ruff/src/rules/flake8_pie/mod.rs +++ b/crates/ruff/src/rules/flake8_pie/mod.rs @@ -12,13 +12,13 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::DuplicateClassFieldDefinition, Path::new("PIE794.py"); "PIE794")] - #[test_case(Rule::UnnecessaryDictKwargs, Path::new("PIE804.py"); "PIE804")] - #[test_case(Rule::MultipleStartsEndsWith, Path::new("PIE810.py"); "PIE810")] - #[test_case(Rule::UnnecessaryPass, Path::new("PIE790.py"); "PIE790")] - #[test_case(Rule::UnnecessarySpread, Path::new("PIE800.py"); "PIE800")] - #[test_case(Rule::ReimplementedListBuiltin, Path::new("PIE807.py"); "PIE807")] - #[test_case(Rule::NonUniqueEnums, Path::new("PIE796.py"); "PIE796")] + #[test_case(Rule::DuplicateClassFieldDefinition, Path::new("PIE794.py"))] + #[test_case(Rule::UnnecessaryDictKwargs, Path::new("PIE804.py"))] + #[test_case(Rule::MultipleStartsEndsWith, Path::new("PIE810.py"))] + #[test_case(Rule::UnnecessaryPass, Path::new("PIE790.py"))] + #[test_case(Rule::UnnecessarySpread, Path::new("PIE800.py"))] + #[test_case(Rule::ReimplementedListBuiltin, Path::new("PIE807.py"))] + #[test_case(Rule::NonUniqueEnums, Path::new("PIE796.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_print/mod.rs b/crates/ruff/src/rules/flake8_print/mod.rs index 4c5087bf0a..3d5179b3e0 100644 --- a/crates/ruff/src/rules/flake8_print/mod.rs +++ b/crates/ruff/src/rules/flake8_print/mod.rs @@ -12,8 +12,8 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::Print, Path::new("T201.py"); "T201")] - #[test_case(Rule::PPrint, Path::new("T203.py"); "T203")] + #[test_case(Rule::Print, Path::new("T201.py"))] + #[test_case(Rule::PPrint, Path::new("T203.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_pytest_style/mod.rs b/crates/ruff/src/rules/flake8_pytest_style/mod.rs index 1c116551a2..c36222950e 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/mod.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/mod.rs @@ -17,7 +17,12 @@ mod tests { use super::settings::Settings; use super::types; - #[test_case(Rule::PytestFixtureIncorrectParenthesesStyle, Path::new("PT001.py"), Settings::default(), "PT001_default"; "PT001_0")] + #[test_case( + Rule::PytestFixtureIncorrectParenthesesStyle, + Path::new("PT001.py"), + Settings::default(), + "PT001_default" + )] #[test_case( Rule::PytestFixtureIncorrectParenthesesStyle, Path::new("PT001.py"), @@ -25,14 +30,38 @@ mod tests { fixture_parentheses: false, ..Settings::default() }, - "PT001_no_parentheses"; - "PT001_1" + "PT001_no_parentheses" + )] + #[test_case( + Rule::PytestFixturePositionalArgs, + Path::new("PT002.py"), + Settings::default(), + "PT002" + )] + #[test_case( + Rule::PytestExtraneousScopeFunction, + Path::new("PT003.py"), + Settings::default(), + "PT003" + )] + #[test_case( + Rule::PytestMissingFixtureNameUnderscore, + Path::new("PT004.py"), + Settings::default(), + "PT004" + )] + #[test_case( + Rule::PytestIncorrectFixtureNameUnderscore, + Path::new("PT005.py"), + Settings::default(), + "PT005" + )] + #[test_case( + Rule::PytestParametrizeNamesWrongType, + Path::new("PT006.py"), + Settings::default(), + "PT006_default" )] - #[test_case(Rule::PytestFixturePositionalArgs, Path::new("PT002.py"), Settings::default(), "PT002"; "PT002")] - #[test_case(Rule::PytestExtraneousScopeFunction, Path::new("PT003.py"), Settings::default(), "PT003"; "PT003")] - #[test_case(Rule::PytestMissingFixtureNameUnderscore, Path::new("PT004.py"), Settings::default(), "PT004"; "PT004")] - #[test_case(Rule::PytestIncorrectFixtureNameUnderscore, Path::new("PT005.py"), Settings::default(), "PT005"; "PT005")] - #[test_case(Rule::PytestParametrizeNamesWrongType, Path::new("PT006.py"), Settings::default(), "PT006_default"; "PT006_0")] #[test_case( Rule::PytestParametrizeNamesWrongType, Path::new("PT006.py"), @@ -40,8 +69,7 @@ mod tests { parametrize_names_type: types::ParametrizeNameType::Csv, ..Settings::default() }, - "PT006_csv"; - "PT006_1" + "PT006_csv" )] #[test_case( Rule::PytestParametrizeNamesWrongType, @@ -50,15 +78,13 @@ mod tests { parametrize_names_type: types::ParametrizeNameType::List, ..Settings::default() }, - "PT006_list"; - "PT006_2" + "PT006_list" )] #[test_case( Rule::PytestParametrizeValuesWrongType, Path::new("PT007.py"), Settings::default(), - "PT007_list_of_tuples"; - "PT007_0" + "PT007_list_of_tuples" )] #[test_case( Rule::PytestParametrizeValuesWrongType, @@ -67,8 +93,7 @@ mod tests { parametrize_values_type: types::ParametrizeValuesType::Tuple, ..Settings::default() }, - "PT007_tuple_of_tuples"; - "PT007_1" + "PT007_tuple_of_tuples" )] #[test_case( Rule::PytestParametrizeValuesWrongType, @@ -78,8 +103,7 @@ mod tests { parametrize_values_row_type: types::ParametrizeValuesRowType::List, ..Settings::default() }, - "PT007_tuple_of_lists"; - "PT007_2" + "PT007_tuple_of_lists" )] #[test_case( Rule::PytestParametrizeValuesWrongType, @@ -88,14 +112,12 @@ mod tests { parametrize_values_row_type: types::ParametrizeValuesRowType::List, ..Settings::default() }, - "PT007_list_of_lists"; - "PT007_3" + "PT007_list_of_lists" )] #[test_case( Rule::PytestPatchWithLambda, Path::new("PT008.py"), Settings::default(), - "PT008"; "PT008" )] #[test_case( @@ -105,13 +127,17 @@ mod tests { "PT009"; "PT009" )] - #[test_case(Rule::PytestRaisesWithoutException, Path::new("PT010.py"), Settings::default(), "PT010"; "PT0010")] + #[test_case( + Rule::PytestRaisesWithoutException, + Path::new("PT010.py"), + Settings::default(), + "PT010" + )] #[test_case( Rule::PytestRaisesTooBroad, Path::new("PT011.py"), Settings::default(), - "PT011_default"; - "PT011_0" + "PT011_default" )] #[test_case( Rule::PytestRaisesTooBroad, @@ -120,8 +146,7 @@ mod tests { raises_extend_require_match_for: vec!["ZeroDivisionError".to_string()], ..Settings::default() }, - "PT011_extend_broad_exceptions"; - "PT011_1" + "PT011_extend_broad_exceptions" )] #[test_case( Rule::PytestRaisesTooBroad, @@ -130,85 +155,73 @@ mod tests { raises_require_match_for: vec!["ZeroDivisionError".to_string()], ..Settings::default() }, - "PT011_replace_broad_exceptions"; - "PT011_2" + "PT011_replace_broad_exceptions" )] #[test_case( Rule::PytestRaisesWithMultipleStatements, Path::new("PT012.py"), Settings::default(), - "PT012"; "PT012" )] #[test_case( Rule::PytestIncorrectPytestImport, Path::new("PT013.py"), Settings::default(), - "PT013"; "PT013" )] #[test_case( Rule::PytestAssertAlwaysFalse, Path::new("PT015.py"), Settings::default(), - "PT015"; "PT015" )] #[test_case( Rule::PytestFailWithoutMessage, Path::new("PT016.py"), Settings::default(), - "PT016"; "PT016" )] #[test_case( Rule::PytestAssertInExcept, Path::new("PT017.py"), Settings::default(), - "PT017"; "PT017" )] #[test_case( Rule::PytestCompositeAssertion, Path::new("PT018.py"), Settings::default(), - "PT018"; "PT018" )] #[test_case( Rule::PytestFixtureParamWithoutValue, Path::new("PT019.py"), Settings::default(), - "PT019"; "PT019" )] #[test_case( Rule::PytestDeprecatedYieldFixture, Path::new("PT020.py"), Settings::default(), - "PT020"; "PT020" )] #[test_case( Rule::PytestFixtureFinalizerCallback, Path::new("PT021.py"), Settings::default(), - "PT021"; "PT021" )] #[test_case( Rule::PytestUselessYieldFixture, Path::new("PT022.py"), Settings::default(), - "PT022"; "PT022" )] #[test_case( Rule::PytestIncorrectMarkParenthesesStyle, Path::new("PT023.py"), Settings::default(), - "PT023_default"; - "PT023_0" + "PT023_default" )] #[test_case( Rule::PytestIncorrectMarkParenthesesStyle, @@ -217,28 +230,24 @@ mod tests { mark_parentheses: false, ..Settings::default() }, - "PT023_no_parentheses"; - "PT023_1" + "PT023_no_parentheses" )] #[test_case( Rule::PytestUnnecessaryAsyncioMarkOnFixture, Path::new("PT024.py"), Settings::default(), - "PT024"; "PT024" )] #[test_case( Rule::PytestErroneousUseFixturesOnFixture, Path::new("PT025.py"), Settings::default(), - "PT025"; "PT025" )] #[test_case( Rule::PytestUseFixturesWithoutParameters, Path::new("PT026.py"), Settings::default(), - "PT026"; "PT026" )] fn test_pytest_style( diff --git a/crates/ruff/src/rules/flake8_raise/mod.rs b/crates/ruff/src/rules/flake8_raise/mod.rs index d5233d1bd4..c6591b3a15 100644 --- a/crates/ruff/src/rules/flake8_raise/mod.rs +++ b/crates/ruff/src/rules/flake8_raise/mod.rs @@ -13,7 +13,7 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::UnnecessaryParenOnRaiseException, Path::new("RSE102.py"); "RSE102")] + #[test_case(Rule::UnnecessaryParenOnRaiseException, Path::new("RSE102.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_return/mod.rs b/crates/ruff/src/rules/flake8_return/mod.rs index cdde36ef05..d07613029a 100644 --- a/crates/ruff/src/rules/flake8_return/mod.rs +++ b/crates/ruff/src/rules/flake8_return/mod.rs @@ -16,14 +16,14 @@ mod tests { use crate::settings::Settings; use crate::test::test_path; - #[test_case(Rule::UnnecessaryReturnNone, Path::new("RET501.py"); "RET501")] - #[test_case(Rule::ImplicitReturnValue, Path::new("RET502.py"); "RET502")] - #[test_case(Rule::ImplicitReturn, Path::new("RET503.py"); "RET503")] - #[test_case(Rule::UnnecessaryAssign, Path::new("RET504.py"); "RET504")] - #[test_case(Rule::SuperfluousElseReturn, Path::new("RET505.py"); "RET505")] - #[test_case(Rule::SuperfluousElseRaise, Path::new("RET506.py"); "RET506")] - #[test_case(Rule::SuperfluousElseContinue, Path::new("RET507.py"); "RET507")] - #[test_case(Rule::SuperfluousElseBreak, Path::new("RET508.py"); "RET508")] + #[test_case(Rule::UnnecessaryReturnNone, Path::new("RET501.py"))] + #[test_case(Rule::ImplicitReturnValue, Path::new("RET502.py"))] + #[test_case(Rule::ImplicitReturn, Path::new("RET503.py"))] + #[test_case(Rule::UnnecessaryAssign, Path::new("RET504.py"))] + #[test_case(Rule::SuperfluousElseReturn, Path::new("RET505.py"))] + #[test_case(Rule::SuperfluousElseRaise, Path::new("RET506.py"))] + #[test_case(Rule::SuperfluousElseContinue, Path::new("RET507.py"))] + #[test_case(Rule::SuperfluousElseBreak, Path::new("RET508.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_self/mod.rs b/crates/ruff/src/rules/flake8_self/mod.rs index debfc7d5e5..3866aa49c4 100644 --- a/crates/ruff/src/rules/flake8_self/mod.rs +++ b/crates/ruff/src/rules/flake8_self/mod.rs @@ -14,7 +14,7 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::PrivateMemberAccess, Path::new("SLF001.py"); "SLF001")] + #[test_case(Rule::PrivateMemberAccess, Path::new("SLF001.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_simplify/mod.rs b/crates/ruff/src/rules/flake8_simplify/mod.rs index 45937fdff0..a942a265ac 100644 --- a/crates/ruff/src/rules/flake8_simplify/mod.rs +++ b/crates/ruff/src/rules/flake8_simplify/mod.rs @@ -12,37 +12,37 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::DuplicateIsinstanceCall, Path::new("SIM101.py"); "SIM101")] - #[test_case(Rule::CollapsibleIf, Path::new("SIM102.py"); "SIM102")] - #[test_case(Rule::NeedlessBool, Path::new("SIM103.py"); "SIM103")] - #[test_case(Rule::SuppressibleException, Path::new("SIM105_0.py"); "SIM105_0")] - #[test_case(Rule::SuppressibleException, Path::new("SIM105_1.py"); "SIM105_1")] - #[test_case(Rule::SuppressibleException, Path::new("SIM105_2.py"); "SIM105_2")] - #[test_case(Rule::SuppressibleException, Path::new("SIM105_3.py"); "SIM105_3")] - #[test_case(Rule::ReturnInTryExceptFinally, Path::new("SIM107.py"); "SIM107")] - #[test_case(Rule::IfElseBlockInsteadOfIfExp, Path::new("SIM108.py"); "SIM108")] - #[test_case(Rule::CompareWithTuple, Path::new("SIM109.py"); "SIM109")] - #[test_case(Rule::ReimplementedBuiltin, Path::new("SIM110.py"); "SIM110")] - #[test_case(Rule::ReimplementedBuiltin, Path::new("SIM111.py"); "SIM111")] - #[test_case(Rule::UncapitalizedEnvironmentVariables, Path::new("SIM112.py"); "SIM112")] - #[test_case(Rule::OpenFileWithContextHandler, Path::new("SIM115.py"); "SIM115")] - #[test_case(Rule::MultipleWithStatements, Path::new("SIM117.py"); "SIM117")] - #[test_case(Rule::InDictKeys, Path::new("SIM118.py"); "SIM118")] - #[test_case(Rule::NegateEqualOp, Path::new("SIM201.py"); "SIM201")] - #[test_case(Rule::NegateNotEqualOp, Path::new("SIM202.py"); "SIM202")] - #[test_case(Rule::DoubleNegation, Path::new("SIM208.py"); "SIM208")] - #[test_case(Rule::IfExprWithTrueFalse, Path::new("SIM210.py"); "SIM210")] - #[test_case(Rule::IfExprWithFalseTrue, Path::new("SIM211.py"); "SIM211")] - #[test_case(Rule::IfExprWithTwistedArms, Path::new("SIM212.py"); "SIM212")] - #[test_case(Rule::ExprAndNotExpr, Path::new("SIM220.py"); "SIM220")] - #[test_case(Rule::ExprOrNotExpr, Path::new("SIM221.py"); "SIM221")] - #[test_case(Rule::ExprOrTrue, Path::new("SIM222.py"); "SIM222")] - #[test_case(Rule::ExprAndFalse, Path::new("SIM223.py"); "SIM223")] - #[test_case(Rule::YodaConditions, Path::new("SIM300.py"); "SIM300")] - #[test_case(Rule::IfElseBlockInsteadOfDictGet, Path::new("SIM401.py"); "SIM401")] - #[test_case(Rule::DictGetWithNoneDefault, Path::new("SIM910.py"); "SIM910")] - #[test_case(Rule::IfElseBlockInsteadOfDictLookup, Path::new("SIM116.py"); "SIM116")] - #[test_case(Rule::IfWithSameArms, Path::new("SIM114.py"); "SIM114")] + #[test_case(Rule::DuplicateIsinstanceCall, Path::new("SIM101.py"))] + #[test_case(Rule::CollapsibleIf, Path::new("SIM102.py"))] + #[test_case(Rule::NeedlessBool, Path::new("SIM103.py"))] + #[test_case(Rule::SuppressibleException, Path::new("SIM105_0.py"))] + #[test_case(Rule::SuppressibleException, Path::new("SIM105_1.py"))] + #[test_case(Rule::SuppressibleException, Path::new("SIM105_2.py"))] + #[test_case(Rule::SuppressibleException, Path::new("SIM105_3.py"))] + #[test_case(Rule::ReturnInTryExceptFinally, Path::new("SIM107.py"))] + #[test_case(Rule::IfElseBlockInsteadOfIfExp, Path::new("SIM108.py"))] + #[test_case(Rule::CompareWithTuple, Path::new("SIM109.py"))] + #[test_case(Rule::ReimplementedBuiltin, Path::new("SIM110.py"))] + #[test_case(Rule::ReimplementedBuiltin, Path::new("SIM111.py"))] + #[test_case(Rule::UncapitalizedEnvironmentVariables, Path::new("SIM112.py"))] + #[test_case(Rule::OpenFileWithContextHandler, Path::new("SIM115.py"))] + #[test_case(Rule::MultipleWithStatements, Path::new("SIM117.py"))] + #[test_case(Rule::InDictKeys, Path::new("SIM118.py"))] + #[test_case(Rule::NegateEqualOp, Path::new("SIM201.py"))] + #[test_case(Rule::NegateNotEqualOp, Path::new("SIM202.py"))] + #[test_case(Rule::DoubleNegation, Path::new("SIM208.py"))] + #[test_case(Rule::IfExprWithTrueFalse, Path::new("SIM210.py"))] + #[test_case(Rule::IfExprWithFalseTrue, Path::new("SIM211.py"))] + #[test_case(Rule::IfExprWithTwistedArms, Path::new("SIM212.py"))] + #[test_case(Rule::ExprAndNotExpr, Path::new("SIM220.py"))] + #[test_case(Rule::ExprOrNotExpr, Path::new("SIM221.py"))] + #[test_case(Rule::ExprOrTrue, Path::new("SIM222.py"))] + #[test_case(Rule::ExprAndFalse, Path::new("SIM223.py"))] + #[test_case(Rule::YodaConditions, Path::new("SIM300.py"))] + #[test_case(Rule::IfElseBlockInsteadOfDictGet, Path::new("SIM401.py"))] + #[test_case(Rule::DictGetWithNoneDefault, Path::new("SIM910.py"))] + #[test_case(Rule::IfElseBlockInsteadOfDictLookup, Path::new("SIM116.py"))] + #[test_case(Rule::IfWithSameArms, Path::new("SIM114.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_todos/mod.rs b/crates/ruff/src/rules/flake8_todos/mod.rs index d95100d4ec..3c30527599 100644 --- a/crates/ruff/src/rules/flake8_todos/mod.rs +++ b/crates/ruff/src/rules/flake8_todos/mod.rs @@ -12,13 +12,13 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::InvalidTodoTag, Path::new("TD001.py"); "TD001")] - #[test_case(Rule::MissingTodoAuthor, Path::new("TD002.py"); "TD002")] - #[test_case(Rule::MissingTodoLink, Path::new("TD003.py"); "TD003")] - #[test_case(Rule::MissingTodoColon, Path::new("TD004.py"); "TD004")] - #[test_case(Rule::MissingTodoDescription, Path::new("TD005.py"); "TD005")] - #[test_case(Rule::InvalidTodoCapitalization, Path::new("TD006.py"); "TD006")] - #[test_case(Rule::MissingSpaceAfterTodoColon, Path::new("TD007.py"); "TD007")] + #[test_case(Rule::InvalidTodoTag, Path::new("TD001.py"))] + #[test_case(Rule::MissingTodoAuthor, Path::new("TD002.py"))] + #[test_case(Rule::MissingTodoLink, Path::new("TD003.py"))] + #[test_case(Rule::MissingTodoColon, Path::new("TD004.py"))] + #[test_case(Rule::MissingTodoDescription, Path::new("TD005.py"))] + #[test_case(Rule::InvalidTodoCapitalization, Path::new("TD006.py"))] + #[test_case(Rule::MissingSpaceAfterTodoColon, Path::new("TD007.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_type_checking/mod.rs b/crates/ruff/src/rules/flake8_type_checking/mod.rs index ff2b1c298c..79a9e6f2b5 100644 --- a/crates/ruff/src/rules/flake8_type_checking/mod.rs +++ b/crates/ruff/src/rules/flake8_type_checking/mod.rs @@ -15,25 +15,25 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[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::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_9.py"); "TCH004_9")] - #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_10.py"); "TCH004_10")] - #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_11.py"); "TCH004_11")] - #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_12.py"); "TCH004_12")] - #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_13.py"); "TCH004_13")] - #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_14.pyi"); "TCH004_14")] - #[test_case(Rule::EmptyTypeCheckingBlock, Path::new("TCH005.py"); "TCH005")] - #[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("strict.py"); "strict")] + #[test_case(Rule::TypingOnlyFirstPartyImport, Path::new("TCH001.py"))] + #[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("TCH002.py"))] + #[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("TCH003.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_1.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_2.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_3.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_4.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_5.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_6.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_7.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_8.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_9.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_10.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_11.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_12.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_13.py"))] + #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_14.pyi"))] + #[test_case(Rule::EmptyTypeCheckingBlock, Path::new("TCH005.py"))] + #[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("strict.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy()); let diagnostics = test_path( @@ -44,7 +44,7 @@ mod tests { Ok(()) } - #[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("strict.py"); "strict")] + #[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("strict.py"))] fn strict(rule_code: Rule, path: &Path) -> Result<()> { let diagnostics = test_path( Path::new("flake8_type_checking").join(path).as_path(), @@ -60,7 +60,7 @@ mod tests { Ok(()) } - #[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("exempt_modules.py"); "exempt_modules")] + #[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("exempt_modules.py"))] fn exempt_modules(rule_code: Rule, path: &Path) -> Result<()> { let diagnostics = test_path( Path::new("flake8_type_checking").join(path).as_path(), @@ -76,9 +76,18 @@ mod tests { Ok(()) } - #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("runtime_evaluated_base_classes_1.py"); "runtime_evaluated_base_classes_1")] - #[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("runtime_evaluated_base_classes_2.py"); "runtime_evaluated_base_classes_2")] - #[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("runtime_evaluated_base_classes_3.py"); "runtime_evaluated_base_classes_3")] + #[test_case( + Rule::RuntimeImportInTypeCheckingBlock, + Path::new("runtime_evaluated_base_classes_1.py") + )] + #[test_case( + Rule::TypingOnlyThirdPartyImport, + Path::new("runtime_evaluated_base_classes_2.py") + )] + #[test_case( + Rule::TypingOnlyStandardLibraryImport, + Path::new("runtime_evaluated_base_classes_3.py") + )] fn runtime_evaluated_base_classes(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy()); let diagnostics = test_path( @@ -95,9 +104,18 @@ mod tests { Ok(()) } - #[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("runtime_evaluated_decorators_1.py"); "runtime_evaluated_decorators_1")] - #[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("runtime_evaluated_decorators_2.py"); "runtime_evaluated_decorators_2")] - #[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("runtime_evaluated_decorators_3.py"); "runtime_evaluated_decorators_3")] + #[test_case( + Rule::RuntimeImportInTypeCheckingBlock, + Path::new("runtime_evaluated_decorators_1.py") + )] + #[test_case( + Rule::TypingOnlyThirdPartyImport, + Path::new("runtime_evaluated_decorators_2.py") + )] + #[test_case( + Rule::TypingOnlyStandardLibraryImport, + Path::new("runtime_evaluated_decorators_3.py") + )] fn runtime_evaluated_decorators(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_unused_arguments/mod.rs b/crates/ruff/src/rules/flake8_unused_arguments/mod.rs index 528a001a69..4875916f5a 100644 --- a/crates/ruff/src/rules/flake8_unused_arguments/mod.rs +++ b/crates/ruff/src/rules/flake8_unused_arguments/mod.rs @@ -14,11 +14,11 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::UnusedFunctionArgument, Path::new("ARG.py"); "ARG001")] - #[test_case(Rule::UnusedMethodArgument, Path::new("ARG.py"); "ARG002")] - #[test_case(Rule::UnusedClassMethodArgument, Path::new("ARG.py"); "ARG003")] - #[test_case(Rule::UnusedStaticMethodArgument, Path::new("ARG.py"); "ARG004")] - #[test_case(Rule::UnusedLambdaArgument, Path::new("ARG.py"); "ARG005")] + #[test_case(Rule::UnusedFunctionArgument, Path::new("ARG.py"))] + #[test_case(Rule::UnusedMethodArgument, Path::new("ARG.py"))] + #[test_case(Rule::UnusedClassMethodArgument, Path::new("ARG.py"))] + #[test_case(Rule::UnusedStaticMethodArgument, Path::new("ARG.py"))] + #[test_case(Rule::UnusedLambdaArgument, Path::new("ARG.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/flake8_use_pathlib/mod.rs b/crates/ruff/src/rules/flake8_use_pathlib/mod.rs index 99f4aca16c..253b5b7222 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/mod.rs +++ b/crates/ruff/src/rules/flake8_use_pathlib/mod.rs @@ -9,15 +9,16 @@ mod tests { use anyhow::Result; use test_case::test_case; + use crate::assert_messages; use crate::registry::Rule; use crate::settings; use crate::test::test_path; - #[test_case(Path::new("full_name.py"); "PTH1_1")] - #[test_case(Path::new("import_as.py"); "PTH1_2")] - #[test_case(Path::new("import_from_as.py"); "PTH1_3")] - #[test_case(Path::new("import_from.py"); "PTH1_4")] - #[test_case(Path::new("use_pathlib.py"); "PTH1_5")] + #[test_case(Path::new("full_name.py"))] + #[test_case(Path::new("import_as.py"))] + #[test_case(Path::new("import_from_as.py"))] + #[test_case(Path::new("import_from.py"))] + #[test_case(Path::new("use_pathlib.py"))] fn rules(path: &Path) -> Result<()> { let snapshot = format!("{}", path.to_string_lossy()); let diagnostics = test_path( @@ -49,19 +50,19 @@ mod tests { Rule::BuiltinOpen, ]), )?; - crate::assert_messages!(snapshot, diagnostics); + assert_messages!(snapshot, diagnostics); Ok(()) } - #[test_case(Rule::PyPath, Path::new("py_path_1.py"); "PTH024_1")] - #[test_case(Rule::PyPath, Path::new("py_path_2.py"); "PTH024_2")] + #[test_case(Rule::PyPath, Path::new("py_path_1.py"))] + #[test_case(Rule::PyPath, Path::new("py_path_2.py"))] fn rules_pypath(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( Path::new("flake8_use_pathlib").join(path).as_path(), &settings::Settings::for_rule(rule_code), )?; - crate::assert_messages!(snapshot, diagnostics); + assert_messages!(snapshot, diagnostics); Ok(()) } } diff --git a/crates/ruff/src/rules/flynt/mod.rs b/crates/ruff/src/rules/flynt/mod.rs index 1644a20480..96bc568cbe 100644 --- a/crates/ruff/src/rules/flynt/mod.rs +++ b/crates/ruff/src/rules/flynt/mod.rs @@ -13,7 +13,7 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::StaticJoinToFString, Path::new("FLY002.py"); "FLY002")] + #[test_case(Rule::StaticJoinToFString, Path::new("FLY002.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/numpy/mod.rs b/crates/ruff/src/rules/numpy/mod.rs index 97a25000e5..37ddc17ffb 100644 --- a/crates/ruff/src/rules/numpy/mod.rs +++ b/crates/ruff/src/rules/numpy/mod.rs @@ -13,8 +13,8 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::NumpyDeprecatedTypeAlias, Path::new("NPY001.py"); "NPY001")] - #[test_case(Rule::NumpyLegacyRandom, Path::new("NPY002.py"); "NPY002")] + #[test_case(Rule::NumpyDeprecatedTypeAlias, Path::new("NPY001.py"))] + #[test_case(Rule::NumpyLegacyRandom, Path::new("NPY002.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/pandas_vet/mod.rs b/crates/ruff/src/rules/pandas_vet/mod.rs index 346caf8137..189182a2e0 100644 --- a/crates/ruff/src/rules/pandas_vet/mod.rs +++ b/crates/ruff/src/rules/pandas_vet/mod.rs @@ -279,7 +279,7 @@ mod tests { rule_code(code, expected); } - #[test_case(Rule::PandasUseOfInplaceArgument, Path::new("PD002.py"); "PD002")] + #[test_case(Rule::PandasUseOfInplaceArgument, Path::new("PD002.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/pep8_naming/mod.rs b/crates/ruff/src/rules/pep8_naming/mod.rs index 8c4f53b04f..98f58c1e12 100644 --- a/crates/ruff/src/rules/pep8_naming/mod.rs +++ b/crates/ruff/src/rules/pep8_naming/mod.rs @@ -15,35 +15,65 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::InvalidClassName, Path::new("N801.py"); "N801")] - #[test_case(Rule::InvalidFunctionName, Path::new("N802.py"); "N802")] - #[test_case(Rule::InvalidArgumentName, Path::new("N803.py"); "N803")] - #[test_case(Rule::InvalidFirstArgumentNameForClassMethod, Path::new("N804.py"); "N804")] - #[test_case(Rule::InvalidFirstArgumentNameForMethod, Path::new("N805.py"); "N805")] - #[test_case(Rule::NonLowercaseVariableInFunction, Path::new("N806.py"); "N806")] - #[test_case(Rule::DunderFunctionName, Path::new("N807.py"); "N807")] - #[test_case(Rule::ConstantImportedAsNonConstant, Path::new("N811.py"); "N811")] - #[test_case(Rule::LowercaseImportedAsNonLowercase, Path::new("N812.py"); "N812")] - #[test_case(Rule::CamelcaseImportedAsLowercase, Path::new("N813.py"); "N813")] - #[test_case(Rule::CamelcaseImportedAsConstant, Path::new("N814.py"); "N814")] - #[test_case(Rule::MixedCaseVariableInClassScope, Path::new("N815.py"); "N815")] - #[test_case(Rule::MixedCaseVariableInGlobalScope, Path::new("N816.py"); "N816")] - #[test_case(Rule::CamelcaseImportedAsAcronym, Path::new("N817.py"); "N817")] - #[test_case(Rule::ErrorSuffixOnExceptionName, Path::new("N818.py"); "N818")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/mod with spaces/__init__.py"); "N999_1")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/mod with spaces/file.py"); "N999_2")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/flake9/__init__.py"); "N999_3")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/MODULE/__init__.py"); "N999_4")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/MODULE/file.py"); "N999_5")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/mod-with-dashes/__init__.py"); "N999_6")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/valid_name/__init__.py"); "N999_7")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/no_module/test.txt"); "N999_8")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/valid_name/file-with-dashes.py"); "N999_9")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/valid_name/__main__.py"); "N999_10")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/invalid_name/0001_initial.py"); "N999_11")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/valid_name/__setup__.py"); "N999_12")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/valid_name/file-with-dashes"); "N999_13")] - #[test_case(Rule::InvalidModuleName, Path::new("N999/module/invalid_name/import.py"); "N999_14")] + #[test_case(Rule::InvalidClassName, Path::new("N801.py"))] + #[test_case(Rule::InvalidFunctionName, Path::new("N802.py"))] + #[test_case(Rule::InvalidArgumentName, Path::new("N803.py"))] + #[test_case(Rule::InvalidFirstArgumentNameForClassMethod, Path::new("N804.py"))] + #[test_case(Rule::InvalidFirstArgumentNameForMethod, Path::new("N805.py"))] + #[test_case(Rule::NonLowercaseVariableInFunction, Path::new("N806.py"))] + #[test_case(Rule::DunderFunctionName, Path::new("N807.py"))] + #[test_case(Rule::ConstantImportedAsNonConstant, Path::new("N811.py"))] + #[test_case(Rule::LowercaseImportedAsNonLowercase, Path::new("N812.py"))] + #[test_case(Rule::CamelcaseImportedAsLowercase, Path::new("N813.py"))] + #[test_case(Rule::CamelcaseImportedAsConstant, Path::new("N814.py"))] + #[test_case(Rule::MixedCaseVariableInClassScope, Path::new("N815.py"))] + #[test_case(Rule::MixedCaseVariableInGlobalScope, Path::new("N816.py"))] + #[test_case(Rule::CamelcaseImportedAsAcronym, Path::new("N817.py"))] + #[test_case(Rule::ErrorSuffixOnExceptionName, Path::new("N818.py"))] + #[test_case( + Rule::InvalidModuleName, + Path::new("N999/module/mod with spaces/__init__.py") + )] + #[test_case( + Rule::InvalidModuleName, + Path::new("N999/module/mod with spaces/file.py") + )] + #[test_case(Rule::InvalidModuleName, Path::new("N999/module/flake9/__init__.py"))] + #[test_case(Rule::InvalidModuleName, Path::new("N999/module/MODULE/__init__.py"))] + #[test_case(Rule::InvalidModuleName, Path::new("N999/module/MODULE/file.py"))] + #[test_case( + Rule::InvalidModuleName, + Path::new("N999/module/mod-with-dashes/__init__.py") + )] + #[test_case( + Rule::InvalidModuleName, + Path::new("N999/module/valid_name/__init__.py") + )] + #[test_case(Rule::InvalidModuleName, Path::new("N999/module/no_module/test.txt"))] + #[test_case( + Rule::InvalidModuleName, + Path::new("N999/module/valid_name/file-with-dashes.py") + )] + #[test_case( + Rule::InvalidModuleName, + Path::new("N999/module/valid_name/__main__.py") + )] + #[test_case( + Rule::InvalidModuleName, + Path::new("N999/module/invalid_name/0001_initial.py") + )] + #[test_case( + Rule::InvalidModuleName, + Path::new("N999/module/valid_name/__setup__.py") + )] + #[test_case( + Rule::InvalidModuleName, + Path::new("N999/module/valid_name/file-with-dashes") + )] + #[test_case( + Rule::InvalidModuleName, + Path::new("N999/module/invalid_name/import.py") + )] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/pydocstyle/mod.rs b/crates/ruff/src/rules/pydocstyle/mod.rs index 86206741d3..9dc0e45fa5 100644 --- a/crates/ruff/src/rules/pydocstyle/mod.rs +++ b/crates/ruff/src/rules/pydocstyle/mod.rs @@ -17,63 +17,72 @@ mod tests { use super::settings::{Convention, Settings}; - #[test_case(Rule::BlankLineAfterLastSection, Path::new("sections.py"); "D413")] - #[test_case(Rule::NoBlankLineAfterSection, Path::new("sections.py"); "D410")] - #[test_case(Rule::BlankLineAfterSummary, Path::new("D.py"); "D205")] - #[test_case(Rule::NoBlankLineBeforeSection, Path::new("sections.py"); "D411")] - #[test_case(Rule::CapitalizeSectionName, Path::new("sections.py"); "D405")] - #[test_case(Rule::DashedUnderlineAfterSection, Path::new("sections.py"); "D407")] - #[test_case(Rule::UndocumentedParam, Path::new("canonical_google_examples.py"); "D417_2")] - #[test_case(Rule::UndocumentedParam, Path::new("canonical_numpy_examples.py"); "D417_1")] - #[test_case(Rule::UndocumentedParam, Path::new("sections.py"); "D417_0")] - #[test_case(Rule::EndsInPeriod, Path::new("D.py"); "D400_0")] - #[test_case(Rule::EndsInPeriod, Path::new("D400.py"); "D400_1")] - #[test_case(Rule::EndsInPunctuation, Path::new("D.py"); "D415")] - #[test_case(Rule::FirstLineCapitalized, Path::new("D.py"); "D403_0")] - #[test_case(Rule::FirstLineCapitalized, Path::new("D403.py"); "D403_1")] - #[test_case(Rule::FitsOnOneLine, Path::new("D.py"); "D200")] - #[test_case(Rule::IndentWithSpaces, Path::new("D.py"); "D206")] - #[test_case(Rule::UndocumentedMagicMethod, Path::new("D.py"); "D105")] - #[test_case(Rule::MultiLineSummaryFirstLine, Path::new("D.py"); "D212")] - #[test_case(Rule::MultiLineSummarySecondLine, Path::new("D.py"); "D213")] - #[test_case(Rule::NewLineAfterLastParagraph, Path::new("D.py"); "D209")] - #[test_case(Rule::NewLineAfterSectionName, Path::new("sections.py"); "D406")] - #[test_case(Rule::NoBlankLineAfterFunction, Path::new("D.py"); "D202_0")] - #[test_case(Rule::NoBlankLineAfterFunction, Path::new("D202.py"); "D202_1")] - #[test_case(Rule::BlankLineBeforeClass, Path::new("D.py"); "D211")] - #[test_case(Rule::NoBlankLineBeforeFunction, Path::new("D.py"); "D201")] - #[test_case(Rule::BlankLinesBetweenHeaderAndContent, Path::new("sections.py"); "D412")] - #[test_case(Rule::OverIndentation, Path::new("D.py"); "D208")] - #[test_case(Rule::NoSignature, Path::new("D.py"); "D402")] - #[test_case(Rule::SurroundingWhitespace, Path::new("D.py"); "D210")] - #[test_case(Rule::DocstringStartsWithThis, Path::new("D.py"); "D404")] - #[test_case(Rule::UnderIndentation, Path::new("D.py"); "D207")] - #[test_case(Rule::EmptyDocstring, Path::new("D.py"); "D419")] - #[test_case(Rule::EmptyDocstringSection, Path::new("sections.py"); "D414")] - #[test_case(Rule::NonImperativeMood, Path::new("D401.py"); "D401")] - #[test_case(Rule::OneBlankLineAfterClass, Path::new("D.py"); "D204")] - #[test_case(Rule::OneBlankLineBeforeClass, Path::new("D.py"); "D203")] - #[test_case(Rule::UndocumentedPublicClass, Path::new("D.py"); "D101")] - #[test_case(Rule::UndocumentedPublicFunction, Path::new("D.py"); "D103")] - #[test_case(Rule::UndocumentedPublicInit, Path::new("D.py"); "D107")] - #[test_case(Rule::UndocumentedPublicMethod, Path::new("D.py"); "D102_0")] - #[test_case(Rule::UndocumentedPublicMethod, Path::new("setter.py"); "D102_1")] - #[test_case(Rule::UndocumentedPublicModule, Path::new("D.py"); "D100")] - #[test_case(Rule::UndocumentedPublicModule, Path::new("_unrelated/pkg/D100_pub.py"); "D100_ignore_unrelated_pub")] - #[test_case(Rule::UndocumentedPublicModule, Path::new("_unrelated/pkg/_priv/no_D100_priv.py"); "no_d100_priv")] - #[test_case(Rule::UndocumentedPublicModule, Path::new("_unrelated/_no_pkg_priv.py"); "no_d100_priv_script")] - #[test_case(Rule::UndocumentedPublicNestedClass, Path::new("D.py"); "D106")] - #[test_case(Rule::UndocumentedPublicPackage, Path::new("D.py"); "D104_0")] - #[test_case(Rule::UndocumentedPublicPackage, Path::new("D104/__init__.py"); "D104_1")] - #[test_case(Rule::SectionNameEndsInColon, Path::new("D.py"); "D416")] - #[test_case(Rule::SectionNotOverIndented, Path::new("sections.py"); "D214")] - #[test_case(Rule::SectionNotOverIndented, Path::new("D214_module.py"); "D214_module")] - #[test_case(Rule::SectionUnderlineAfterName, Path::new("sections.py"); "D408")] - #[test_case(Rule::SectionUnderlineMatchesSectionLength, Path::new("sections.py"); "D409")] - #[test_case(Rule::SectionUnderlineNotOverIndented, Path::new("sections.py"); "D215")] - #[test_case(Rule::OverloadWithDocstring, Path::new("D.py"); "D418")] - #[test_case(Rule::EscapeSequenceInDocstring, Path::new("D.py"); "D301")] - #[test_case(Rule::TripleSingleQuotes, Path::new("D.py"); "D300")] + #[test_case(Rule::BlankLineAfterLastSection, Path::new("sections.py"))] + #[test_case(Rule::NoBlankLineAfterSection, Path::new("sections.py"))] + #[test_case(Rule::BlankLineAfterSummary, Path::new("D.py"))] + #[test_case(Rule::NoBlankLineBeforeSection, Path::new("sections.py"))] + #[test_case(Rule::CapitalizeSectionName, Path::new("sections.py"))] + #[test_case(Rule::DashedUnderlineAfterSection, Path::new("sections.py"))] + #[test_case(Rule::UndocumentedParam, Path::new("canonical_google_examples.py"))] + #[test_case(Rule::UndocumentedParam, Path::new("canonical_numpy_examples.py"))] + #[test_case(Rule::UndocumentedParam, Path::new("sections.py"))] + #[test_case(Rule::EndsInPeriod, Path::new("D.py"))] + #[test_case(Rule::EndsInPeriod, Path::new("D400.py"))] + #[test_case(Rule::EndsInPunctuation, Path::new("D.py"))] + #[test_case(Rule::FirstLineCapitalized, Path::new("D.py"))] + #[test_case(Rule::FirstLineCapitalized, Path::new("D403.py"))] + #[test_case(Rule::FitsOnOneLine, Path::new("D.py"))] + #[test_case(Rule::IndentWithSpaces, Path::new("D.py"))] + #[test_case(Rule::UndocumentedMagicMethod, Path::new("D.py"))] + #[test_case(Rule::MultiLineSummaryFirstLine, Path::new("D.py"))] + #[test_case(Rule::MultiLineSummarySecondLine, Path::new("D.py"))] + #[test_case(Rule::NewLineAfterLastParagraph, Path::new("D.py"))] + #[test_case(Rule::NewLineAfterSectionName, Path::new("sections.py"))] + #[test_case(Rule::NoBlankLineAfterFunction, Path::new("D.py"))] + #[test_case(Rule::NoBlankLineAfterFunction, Path::new("D202.py"))] + #[test_case(Rule::BlankLineBeforeClass, Path::new("D.py"))] + #[test_case(Rule::NoBlankLineBeforeFunction, Path::new("D.py"))] + #[test_case(Rule::BlankLinesBetweenHeaderAndContent, Path::new("sections.py"))] + #[test_case(Rule::OverIndentation, Path::new("D.py"))] + #[test_case(Rule::NoSignature, Path::new("D.py"))] + #[test_case(Rule::SurroundingWhitespace, Path::new("D.py"))] + #[test_case(Rule::DocstringStartsWithThis, Path::new("D.py"))] + #[test_case(Rule::UnderIndentation, Path::new("D.py"))] + #[test_case(Rule::EmptyDocstring, Path::new("D.py"))] + #[test_case(Rule::EmptyDocstringSection, Path::new("sections.py"))] + #[test_case(Rule::NonImperativeMood, Path::new("D401.py"))] + #[test_case(Rule::OneBlankLineAfterClass, Path::new("D.py"))] + #[test_case(Rule::OneBlankLineBeforeClass, Path::new("D.py"))] + #[test_case(Rule::UndocumentedPublicClass, Path::new("D.py"))] + #[test_case(Rule::UndocumentedPublicFunction, Path::new("D.py"))] + #[test_case(Rule::UndocumentedPublicInit, Path::new("D.py"))] + #[test_case(Rule::UndocumentedPublicMethod, Path::new("D.py"))] + #[test_case(Rule::UndocumentedPublicMethod, Path::new("setter.py"))] + #[test_case(Rule::UndocumentedPublicModule, Path::new("D.py"))] + #[test_case( + Rule::UndocumentedPublicModule, + Path::new("_unrelated/pkg/D100_pub.py") + )] + #[test_case( + Rule::UndocumentedPublicModule, + Path::new("_unrelated/pkg/_priv/no_D100_priv.py") + )] + #[test_case( + Rule::UndocumentedPublicModule, + Path::new("_unrelated/_no_pkg_priv.py") + )] + #[test_case(Rule::UndocumentedPublicNestedClass, Path::new("D.py"))] + #[test_case(Rule::UndocumentedPublicPackage, Path::new("D.py"))] + #[test_case(Rule::UndocumentedPublicPackage, Path::new("D104/__init__.py"))] + #[test_case(Rule::SectionNameEndsInColon, Path::new("D.py"))] + #[test_case(Rule::SectionNotOverIndented, Path::new("sections.py"))] + #[test_case(Rule::SectionNotOverIndented, Path::new("D214_module.py"))] + #[test_case(Rule::SectionUnderlineAfterName, Path::new("sections.py"))] + #[test_case(Rule::SectionUnderlineMatchesSectionLength, Path::new("sections.py"))] + #[test_case(Rule::SectionUnderlineNotOverIndented, Path::new("sections.py"))] + #[test_case(Rule::OverloadWithDocstring, Path::new("D.py"))] + #[test_case(Rule::EscapeSequenceInDocstring, Path::new("D.py"))] + #[test_case(Rule::TripleSingleQuotes, Path::new("D.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/pyflakes/mod.rs b/crates/ruff/src/rules/pyflakes/mod.rs index 052c759047..7921a91050 100644 --- a/crates/ruff/src/rules/pyflakes/mod.rs +++ b/crates/ruff/src/rules/pyflakes/mod.rs @@ -23,110 +23,110 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, directives, settings}; - #[test_case(Rule::UnusedImport, Path::new("F401_0.py"); "F401_0")] - #[test_case(Rule::UnusedImport, Path::new("F401_1.py"); "F401_1")] - #[test_case(Rule::UnusedImport, Path::new("F401_2.py"); "F401_2")] - #[test_case(Rule::UnusedImport, Path::new("F401_3.py"); "F401_3")] - #[test_case(Rule::UnusedImport, Path::new("F401_4.py"); "F401_4")] - #[test_case(Rule::UnusedImport, Path::new("F401_5.py"); "F401_5")] - #[test_case(Rule::UnusedImport, Path::new("F401_6.py"); "F401_6")] - #[test_case(Rule::UnusedImport, Path::new("F401_7.py"); "F401_7")] - #[test_case(Rule::UnusedImport, Path::new("F401_8.py"); "F401_8")] - #[test_case(Rule::UnusedImport, Path::new("F401_9.py"); "F401_9")] - #[test_case(Rule::UnusedImport, Path::new("F401_10.py"); "F401_10")] - #[test_case(Rule::UnusedImport, Path::new("F401_11.py"); "F401_11")] - #[test_case(Rule::UnusedImport, Path::new("F401_12.py"); "F401_12")] - #[test_case(Rule::UnusedImport, Path::new("F401_13.py"); "F401_13")] - #[test_case(Rule::UnusedImport, Path::new("F401_14.py"); "F401_14")] - #[test_case(Rule::ImportShadowedByLoopVar, Path::new("F402.py"); "F402")] - #[test_case(Rule::UndefinedLocalWithImportStar, Path::new("F403.py"); "F403")] - #[test_case(Rule::LateFutureImport, Path::new("F404.py"); "F404")] - #[test_case(Rule::UndefinedLocalWithImportStarUsage, Path::new("F405.py"); "F405")] - #[test_case(Rule::UndefinedLocalWithNestedImportStarUsage, Path::new("F406.py"); "F406")] - #[test_case(Rule::FutureFeatureNotDefined, Path::new("F407.py"); "F407")] - #[test_case(Rule::PercentFormatInvalidFormat, Path::new("F50x.py"); "F501")] - #[test_case(Rule::PercentFormatExpectedMapping, Path::new("F502.py"); "F502_1")] - #[test_case(Rule::PercentFormatExpectedMapping, Path::new("F50x.py"); "F502_0")] - #[test_case(Rule::PercentFormatExpectedSequence, Path::new("F503.py"); "F503_1")] - #[test_case(Rule::PercentFormatExpectedSequence, Path::new("F50x.py"); "F503_0")] - #[test_case(Rule::PercentFormatExtraNamedArguments, Path::new("F504.py"); "F504_1")] - #[test_case(Rule::PercentFormatExtraNamedArguments, Path::new("F50x.py"); "F504_0")] - #[test_case(Rule::PercentFormatMissingArgument, Path::new("F504.py"); "F505_1")] - #[test_case(Rule::PercentFormatMissingArgument, Path::new("F50x.py"); "F505_0")] - #[test_case(Rule::PercentFormatMixedPositionalAndNamed, Path::new("F50x.py"); "F506")] - #[test_case(Rule::PercentFormatPositionalCountMismatch, Path::new("F50x.py"); "F507")] - #[test_case(Rule::PercentFormatStarRequiresSequence, Path::new("F50x.py"); "F508")] - #[test_case(Rule::PercentFormatUnsupportedFormatCharacter, Path::new("F50x.py"); "F509")] - #[test_case(Rule::StringDotFormatInvalidFormat, Path::new("F521.py"); "F521")] - #[test_case(Rule::StringDotFormatExtraNamedArguments, Path::new("F522.py"); "F522")] - #[test_case(Rule::StringDotFormatExtraPositionalArguments, Path::new("F523.py"); "F523")] - #[test_case(Rule::StringDotFormatMissingArguments, Path::new("F524.py"); "F524")] - #[test_case(Rule::StringDotFormatMixingAutomatic, Path::new("F525.py"); "F525")] - #[test_case(Rule::FStringMissingPlaceholders, Path::new("F541.py"); "F541")] - #[test_case(Rule::MultiValueRepeatedKeyLiteral, Path::new("F601.py"); "F601")] - #[test_case(Rule::MultiValueRepeatedKeyVariable, Path::new("F602.py"); "F602")] - #[test_case(Rule::MultipleStarredExpressions, Path::new("F622.py"); "F622")] - #[test_case(Rule::AssertTuple, Path::new("F631.py"); "F631")] - #[test_case(Rule::IsLiteral, Path::new("F632.py"); "F632")] - #[test_case(Rule::InvalidPrintSyntax, Path::new("F633.py"); "F633")] - #[test_case(Rule::IfTuple, Path::new("F634.py"); "F634")] - #[test_case(Rule::BreakOutsideLoop, Path::new("F701.py"); "F701")] - #[test_case(Rule::ContinueOutsideLoop, Path::new("F702.py"); "F702")] - #[test_case(Rule::YieldOutsideFunction, Path::new("F704.py"); "F704")] - #[test_case(Rule::ReturnOutsideFunction, Path::new("F706.py"); "F706")] - #[test_case(Rule::DefaultExceptNotLast, Path::new("F707.py"); "F707")] - #[test_case(Rule::ForwardAnnotationSyntaxError, Path::new("F722.py"); "F722")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_0.py"); "F811_0")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_1.py"); "F811_1")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_2.py"); "F811_2")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_3.py"); "F811_3")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_4.py"); "F811_4")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_5.py"); "F811_5")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_6.py"); "F811_6")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_7.py"); "F811_7")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_8.py"); "F811_8")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_9.py"); "F811_9")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_10.py"); "F811_10")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_11.py"); "F811_11")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_12.py"); "F811_12")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_13.py"); "F811_13")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_14.py"); "F811_14")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_15.py"); "F811_15")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_16.py"); "F811_16")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_17.py"); "F811_17")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_18.py"); "F811_18")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_19.py"); "F811_19")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_20.py"); "F811_20")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_21.py"); "F811_21")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_22.py"); "F811_22")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_23.py"); "F811_23")] - #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_24.py"); "F811_24")] - #[test_case(Rule::UndefinedName, Path::new("F821_0.py"); "F821_0")] - #[test_case(Rule::UndefinedName, Path::new("F821_1.py"); "F821_1")] - #[test_case(Rule::UndefinedName, Path::new("F821_2.py"); "F821_2")] - #[test_case(Rule::UndefinedName, Path::new("F821_3.py"); "F821_3")] - #[test_case(Rule::UndefinedName, Path::new("F821_4.py"); "F821_4")] - #[test_case(Rule::UndefinedName, Path::new("F821_5.py"); "F821_5")] - #[test_case(Rule::UndefinedName, Path::new("F821_6.py"); "F821_6")] - #[test_case(Rule::UndefinedName, Path::new("F821_7.py"); "F821_7")] - #[test_case(Rule::UndefinedName, Path::new("F821_8.pyi"); "F821_8")] - #[test_case(Rule::UndefinedName, Path::new("F821_9.py"); "F821_9")] - #[test_case(Rule::UndefinedName, Path::new("F821_10.py"); "F821_10")] - #[test_case(Rule::UndefinedName, Path::new("F821_11.py"); "F821_11")] - #[test_case(Rule::UndefinedName, Path::new("F821_12.py"); "F821_12")] - #[test_case(Rule::UndefinedName, Path::new("F821_13.py"); "F821_13")] - #[test_case(Rule::UndefinedName, Path::new("F821_14.py"); "F821_14")] - #[test_case(Rule::UndefinedName, Path::new("F821_15.py"); "F821_15")] - #[test_case(Rule::UndefinedExport, Path::new("F822_0.py"); "F822_0")] - #[test_case(Rule::UndefinedExport, Path::new("F822_1.py"); "F822_1")] - #[test_case(Rule::UndefinedExport, Path::new("F822_2.py"); "F822_2")] - #[test_case(Rule::UndefinedLocal, Path::new("F823.py"); "F823")] - #[test_case(Rule::UnusedVariable, Path::new("F841_0.py"); "F841_0")] - #[test_case(Rule::UnusedVariable, Path::new("F841_1.py"); "F841_1")] - #[test_case(Rule::UnusedVariable, Path::new("F841_2.py"); "F841_2")] - #[test_case(Rule::UnusedVariable, Path::new("F841_3.py"); "F841_3")] - #[test_case(Rule::UnusedAnnotation, Path::new("F842.py"); "F842")] - #[test_case(Rule::RaiseNotImplemented, Path::new("F901.py"); "F901")] + #[test_case(Rule::UnusedImport, Path::new("F401_0.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_1.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_2.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_3.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_4.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_5.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_6.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_7.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_8.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_9.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_10.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_11.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_12.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_13.py"))] + #[test_case(Rule::UnusedImport, Path::new("F401_14.py"))] + #[test_case(Rule::ImportShadowedByLoopVar, Path::new("F402.py"))] + #[test_case(Rule::UndefinedLocalWithImportStar, Path::new("F403.py"))] + #[test_case(Rule::LateFutureImport, Path::new("F404.py"))] + #[test_case(Rule::UndefinedLocalWithImportStarUsage, Path::new("F405.py"))] + #[test_case(Rule::UndefinedLocalWithNestedImportStarUsage, Path::new("F406.py"))] + #[test_case(Rule::FutureFeatureNotDefined, Path::new("F407.py"))] + #[test_case(Rule::PercentFormatInvalidFormat, Path::new("F50x.py"))] + #[test_case(Rule::PercentFormatExpectedMapping, Path::new("F502.py"))] + #[test_case(Rule::PercentFormatExpectedMapping, Path::new("F50x.py"))] + #[test_case(Rule::PercentFormatExpectedSequence, Path::new("F503.py"))] + #[test_case(Rule::PercentFormatExpectedSequence, Path::new("F50x.py"))] + #[test_case(Rule::PercentFormatExtraNamedArguments, Path::new("F504.py"))] + #[test_case(Rule::PercentFormatExtraNamedArguments, Path::new("F50x.py"))] + #[test_case(Rule::PercentFormatMissingArgument, Path::new("F504.py"))] + #[test_case(Rule::PercentFormatMissingArgument, Path::new("F50x.py"))] + #[test_case(Rule::PercentFormatMixedPositionalAndNamed, Path::new("F50x.py"))] + #[test_case(Rule::PercentFormatPositionalCountMismatch, Path::new("F50x.py"))] + #[test_case(Rule::PercentFormatStarRequiresSequence, Path::new("F50x.py"))] + #[test_case(Rule::PercentFormatUnsupportedFormatCharacter, Path::new("F50x.py"))] + #[test_case(Rule::StringDotFormatInvalidFormat, Path::new("F521.py"))] + #[test_case(Rule::StringDotFormatExtraNamedArguments, Path::new("F522.py"))] + #[test_case(Rule::StringDotFormatExtraPositionalArguments, Path::new("F523.py"))] + #[test_case(Rule::StringDotFormatMissingArguments, Path::new("F524.py"))] + #[test_case(Rule::StringDotFormatMixingAutomatic, Path::new("F525.py"))] + #[test_case(Rule::FStringMissingPlaceholders, Path::new("F541.py"))] + #[test_case(Rule::MultiValueRepeatedKeyLiteral, Path::new("F601.py"))] + #[test_case(Rule::MultiValueRepeatedKeyVariable, Path::new("F602.py"))] + #[test_case(Rule::MultipleStarredExpressions, Path::new("F622.py"))] + #[test_case(Rule::AssertTuple, Path::new("F631.py"))] + #[test_case(Rule::IsLiteral, Path::new("F632.py"))] + #[test_case(Rule::InvalidPrintSyntax, Path::new("F633.py"))] + #[test_case(Rule::IfTuple, Path::new("F634.py"))] + #[test_case(Rule::BreakOutsideLoop, Path::new("F701.py"))] + #[test_case(Rule::ContinueOutsideLoop, Path::new("F702.py"))] + #[test_case(Rule::YieldOutsideFunction, Path::new("F704.py"))] + #[test_case(Rule::ReturnOutsideFunction, Path::new("F706.py"))] + #[test_case(Rule::DefaultExceptNotLast, Path::new("F707.py"))] + #[test_case(Rule::ForwardAnnotationSyntaxError, Path::new("F722.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_0.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_1.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_2.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_3.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_4.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_5.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_6.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_7.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_8.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_9.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_10.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_11.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_12.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_13.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_14.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_15.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_16.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_17.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_18.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_19.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_20.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_21.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_22.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_23.py"))] + #[test_case(Rule::RedefinedWhileUnused, Path::new("F811_24.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_0.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_1.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_2.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_3.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_4.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_5.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_6.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_7.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_8.pyi"))] + #[test_case(Rule::UndefinedName, Path::new("F821_9.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_10.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_11.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_12.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_13.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_14.py"))] + #[test_case(Rule::UndefinedName, Path::new("F821_15.py"))] + #[test_case(Rule::UndefinedExport, Path::new("F822_0.py"))] + #[test_case(Rule::UndefinedExport, Path::new("F822_1.py"))] + #[test_case(Rule::UndefinedExport, Path::new("F822_2.py"))] + #[test_case(Rule::UndefinedLocal, Path::new("F823.py"))] + #[test_case(Rule::UnusedVariable, Path::new("F841_0.py"))] + #[test_case(Rule::UnusedVariable, Path::new("F841_1.py"))] + #[test_case(Rule::UnusedVariable, Path::new("F841_2.py"))] + #[test_case(Rule::UnusedVariable, Path::new("F841_3.py"))] + #[test_case(Rule::UnusedAnnotation, Path::new("F842.py"))] + #[test_case(Rule::RaiseNotImplemented, Path::new("F901.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/pygrep_hooks/mod.rs b/crates/ruff/src/rules/pygrep_hooks/mod.rs index 38b9333b13..a19bfe9adb 100644 --- a/crates/ruff/src/rules/pygrep_hooks/mod.rs +++ b/crates/ruff/src/rules/pygrep_hooks/mod.rs @@ -12,14 +12,14 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::Eval, Path::new("PGH001_0.py"); "PGH001_0")] - #[test_case(Rule::Eval, Path::new("PGH001_1.py"); "PGH001_1")] - #[test_case(Rule::DeprecatedLogWarn, Path::new("PGH002_0.py"); "PGH002_0")] - #[test_case(Rule::DeprecatedLogWarn, Path::new("PGH002_1.py"); "PGH002_1")] - #[test_case(Rule::BlanketTypeIgnore, Path::new("PGH003_0.py"); "PGH003_0")] - #[test_case(Rule::BlanketTypeIgnore, Path::new("PGH003_1.py"); "PGH003_1")] - #[test_case(Rule::BlanketNOQA, Path::new("PGH004_0.py"); "PGH004_0")] - #[test_case(Rule::InvalidMockAccess, Path::new("PGH005_0.py"); "PGH005_0")] + #[test_case(Rule::Eval, Path::new("PGH001_0.py"))] + #[test_case(Rule::Eval, Path::new("PGH001_1.py"))] + #[test_case(Rule::DeprecatedLogWarn, Path::new("PGH002_0.py"))] + #[test_case(Rule::DeprecatedLogWarn, Path::new("PGH002_1.py"))] + #[test_case(Rule::BlanketTypeIgnore, Path::new("PGH003_0.py"))] + #[test_case(Rule::BlanketTypeIgnore, Path::new("PGH003_1.py"))] + #[test_case(Rule::BlanketNOQA, Path::new("PGH004_0.py"))] + #[test_case(Rule::InvalidMockAccess, Path::new("PGH005_0.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/pylint/mod.rs b/crates/ruff/src/rules/pylint/mod.rs index 6381344785..523eb62e8c 100644 --- a/crates/ruff/src/rules/pylint/mod.rs +++ b/crates/ruff/src/rules/pylint/mod.rs @@ -18,64 +18,91 @@ mod tests { use crate::settings::Settings; use crate::test::test_path; - #[test_case(Rule::AwaitOutsideAsync, Path::new("await_outside_async.py"); "PLE1142")] - #[test_case(Rule::AssertOnStringLiteral, Path::new("assert_on_string_literal.py"); "PLW0129")] - #[test_case(Rule::BadStrStripCall, Path::new("bad_str_strip_call.py"); "PLE1310")] - #[test_case(Rule::BadStringFormatType, Path::new("bad_string_format_type.py"); "PLE1307")] - #[test_case(Rule::BidirectionalUnicode, Path::new("bidirectional_unicode.py"); "PLE2502")] - #[test_case(Rule::BinaryOpException, Path::new("binary_op_exception.py"); "PLW0711")] - #[test_case(Rule::CollapsibleElseIf, Path::new("collapsible_else_if.py"); "PLR5501")] - #[test_case(Rule::CompareToEmptyString, Path::new("compare_to_empty_string.py"); "PLC1901")] - #[test_case(Rule::ComparisonOfConstant, Path::new("comparison_of_constant.py"); "PLR0133")] - #[test_case(Rule::RepeatedIsinstanceCalls, Path::new("repeated_isinstance_calls.py"); "PLR1701")] - #[test_case(Rule::ManualFromImport, Path::new("import_aliasing.py"); "PLR0402")] - #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_0.py"); "PLR1722_0")] - #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_1.py"); "PLR1722_1")] - #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_2.py"); "PLR1722_2")] - #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_3.py"); "PLR1722_3")] - #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_4.py"); "PLR1722_4")] - #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_5.py"); "PLR1722_5")] - #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_6.py"); "PLR1722_6")] - #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_7.py"); "PLR1722_7")] - #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_8.py"); "PLR1722_8")] - #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_9.py"); "PLR1722_9")] - #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_10.py"); "PLR1722_10")] - #[test_case(Rule::ContinueInFinally, Path::new("continue_in_finally.py"); "PLE0116")] - #[test_case(Rule::GlobalStatement, Path::new("global_statement.py"); "PLW0603")] - #[test_case(Rule::GlobalVariableNotAssigned, Path::new("global_variable_not_assigned.py"); "PLW0602")] - #[test_case(Rule::ImportSelf, Path::new("import_self/module.py"); "PLW0406")] - #[test_case(Rule::InvalidAllFormat, Path::new("invalid_all_format.py"); "PLE0605")] - #[test_case(Rule::InvalidAllObject, Path::new("invalid_all_object.py"); "PLE0604")] - #[test_case(Rule::DuplicateBases, Path::new("duplicate_bases.py"); "PLE0241")] - #[test_case(Rule::DuplicateValue, Path::new("duplicate_value.py"); "PLW0130")] - #[test_case(Rule::InvalidCharacterBackspace, Path::new("invalid_characters.py"); "PLE2510")] - #[test_case(Rule::InvalidCharacterEsc, Path::new("invalid_characters.py"); "PLE2513")] - #[test_case(Rule::InvalidCharacterNul, Path::new("invalid_characters.py"); "PLE2514")] - #[test_case(Rule::InvalidCharacterSub, Path::new("invalid_characters.py"); "PLE2512")] - #[test_case(Rule::InvalidCharacterZeroWidthSpace, Path::new("invalid_characters.py"); "PLE2515")] - #[test_case(Rule::InvalidEnvvarDefault, Path::new("invalid_envvar_default.py"); "PLW1508")] - #[test_case(Rule::InvalidEnvvarValue, Path::new("invalid_envvar_value.py"); "PLE1507")] - #[test_case(Rule::LoggingTooFewArgs, Path::new("logging_too_few_args.py"); "PLE1206")] - #[test_case(Rule::LoggingTooManyArgs, Path::new("logging_too_many_args.py"); "PLE1205")] - #[test_case(Rule::MagicValueComparison, Path::new("magic_value_comparison.py"); "PLR2004")] - #[test_case(Rule::NamedExprWithoutContext, Path::new("named_expr_without_context.py"); "PLW0131")] - #[test_case(Rule::NonlocalWithoutBinding, Path::new("nonlocal_without_binding.py"); "PLE0117")] - #[test_case(Rule::PropertyWithParameters, Path::new("property_with_parameters.py"); "PLR0206")] - #[test_case(Rule::RedefinedLoopName, Path::new("redefined_loop_name.py"); "PLW2901")] - #[test_case(Rule::ReturnInInit, Path::new("return_in_init.py"); "PLE0101")] - #[test_case(Rule::TooManyArguments, Path::new("too_many_arguments.py"); "PLR0913")] - #[test_case(Rule::TooManyBranches, Path::new("too_many_branches.py"); "PLR0912")] - #[test_case(Rule::TooManyReturnStatements, Path::new("too_many_return_statements.py"); "PLR0911")] - #[test_case(Rule::TooManyStatements, Path::new("too_many_statements.py"); "PLR0915")] - #[test_case(Rule::UnexpectedSpecialMethodSignature, Path::new("unexpected_special_method_signature.py"); "PLE0302")] - #[test_case(Rule::UnnecessaryDirectLambdaCall, Path::new("unnecessary_direct_lambda_call.py"); "PLC3002")] - #[test_case(Rule::LoadBeforeGlobalDeclaration, Path::new("load_before_global_declaration.py"); "PLE0118")] - #[test_case(Rule::UselessElseOnLoop, Path::new("useless_else_on_loop.py"); "PLW0120")] - #[test_case(Rule::UselessImportAlias, Path::new("import_aliasing.py"); "PLC0414")] - #[test_case(Rule::UselessReturn, Path::new("useless_return.py"); "PLR1711")] - #[test_case(Rule::YieldFromInAsyncFunction, Path::new("yield_from_in_async_function.py"); "PLE1700")] - #[test_case(Rule::YieldInInit, Path::new("yield_in_init.py"); "PLE0100")] - #[test_case(Rule::NestedMinMax, Path::new("nested_min_max.py"); "PLW3301")] + #[test_case(Rule::AwaitOutsideAsync, Path::new("await_outside_async.py"))] + #[test_case(Rule::AssertOnStringLiteral, Path::new("assert_on_string_literal.py"))] + #[test_case(Rule::BadStrStripCall, Path::new("bad_str_strip_call.py"))] + #[test_case(Rule::BadStringFormatType, Path::new("bad_string_format_type.py"))] + #[test_case(Rule::BidirectionalUnicode, Path::new("bidirectional_unicode.py"))] + #[test_case(Rule::BinaryOpException, Path::new("binary_op_exception.py"))] + #[test_case(Rule::CollapsibleElseIf, Path::new("collapsible_else_if.py"))] + #[test_case(Rule::CompareToEmptyString, Path::new("compare_to_empty_string.py"))] + #[test_case(Rule::ComparisonOfConstant, Path::new("comparison_of_constant.py"))] + #[test_case( + Rule::RepeatedIsinstanceCalls, + Path::new("repeated_isinstance_calls.py") + )] + #[test_case(Rule::ManualFromImport, Path::new("import_aliasing.py"))] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_0.py"))] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_1.py"))] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_2.py"))] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_3.py"))] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_4.py"))] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_5.py"))] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_6.py"))] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_7.py"))] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_8.py"))] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_9.py"))] + #[test_case(Rule::SysExitAlias, Path::new("sys_exit_alias_10.py"))] + #[test_case(Rule::ContinueInFinally, Path::new("continue_in_finally.py"))] + #[test_case(Rule::GlobalStatement, Path::new("global_statement.py"))] + #[test_case( + Rule::GlobalVariableNotAssigned, + Path::new("global_variable_not_assigned.py") + )] + #[test_case(Rule::ImportSelf, Path::new("import_self/module.py"))] + #[test_case(Rule::InvalidAllFormat, Path::new("invalid_all_format.py"))] + #[test_case(Rule::InvalidAllObject, Path::new("invalid_all_object.py"))] + #[test_case(Rule::DuplicateBases, Path::new("duplicate_bases.py"))] + #[test_case(Rule::DuplicateValue, Path::new("duplicate_value.py"))] + #[test_case(Rule::InvalidCharacterBackspace, Path::new("invalid_characters.py"))] + #[test_case(Rule::InvalidCharacterEsc, Path::new("invalid_characters.py"))] + #[test_case(Rule::InvalidCharacterNul, Path::new("invalid_characters.py"))] + #[test_case(Rule::InvalidCharacterSub, Path::new("invalid_characters.py"))] + #[test_case( + Rule::InvalidCharacterZeroWidthSpace, + Path::new("invalid_characters.py") + )] + #[test_case(Rule::InvalidEnvvarDefault, Path::new("invalid_envvar_default.py"))] + #[test_case(Rule::InvalidEnvvarValue, Path::new("invalid_envvar_value.py"))] + #[test_case(Rule::LoggingTooFewArgs, Path::new("logging_too_few_args.py"))] + #[test_case(Rule::LoggingTooManyArgs, Path::new("logging_too_many_args.py"))] + #[test_case(Rule::MagicValueComparison, Path::new("magic_value_comparison.py"))] + #[test_case( + Rule::NamedExprWithoutContext, + Path::new("named_expr_without_context.py") + )] + #[test_case(Rule::NonlocalWithoutBinding, Path::new("nonlocal_without_binding.py"))] + #[test_case(Rule::PropertyWithParameters, Path::new("property_with_parameters.py"))] + #[test_case(Rule::RedefinedLoopName, Path::new("redefined_loop_name.py"))] + #[test_case(Rule::ReturnInInit, Path::new("return_in_init.py"))] + #[test_case(Rule::TooManyArguments, Path::new("too_many_arguments.py"))] + #[test_case(Rule::TooManyBranches, Path::new("too_many_branches.py"))] + #[test_case( + Rule::TooManyReturnStatements, + Path::new("too_many_return_statements.py") + )] + #[test_case(Rule::TooManyStatements, Path::new("too_many_statements.py"))] + #[test_case( + Rule::UnexpectedSpecialMethodSignature, + Path::new("unexpected_special_method_signature.py") + )] + #[test_case( + Rule::UnnecessaryDirectLambdaCall, + Path::new("unnecessary_direct_lambda_call.py") + )] + #[test_case( + Rule::LoadBeforeGlobalDeclaration, + Path::new("load_before_global_declaration.py") + )] + #[test_case(Rule::UselessElseOnLoop, Path::new("useless_else_on_loop.py"))] + #[test_case(Rule::UselessImportAlias, Path::new("import_aliasing.py"))] + #[test_case(Rule::UselessReturn, Path::new("useless_return.py"))] + #[test_case( + Rule::YieldFromInAsyncFunction, + Path::new("yield_from_in_async_function.py") + )] + #[test_case(Rule::YieldInInit, Path::new("yield_in_init.py"))] + #[test_case(Rule::NestedMinMax, Path::new("nested_min_max.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/pyupgrade/mod.rs b/crates/ruff/src/rules/pyupgrade/mod.rs index cc3911bfb5..331194a03d 100644 --- a/crates/ruff/src/rules/pyupgrade/mod.rs +++ b/crates/ruff/src/rules/pyupgrade/mod.rs @@ -16,64 +16,64 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::UselessMetaclassType, Path::new("UP001.py"); "UP001")] - #[test_case(Rule::TypeOfPrimitive, Path::new("UP003.py"); "UP003")] - #[test_case(Rule::UselessObjectInheritance, Path::new("UP004.py"); "UP004")] - #[test_case(Rule::DeprecatedUnittestAlias, Path::new("UP005.py"); "UP005")] - #[test_case(Rule::NonPEP585Annotation, Path::new("UP006_0.py"); "UP006_0")] - #[test_case(Rule::NonPEP585Annotation, Path::new("UP006_1.py"); "UP006_1")] - #[test_case(Rule::NonPEP585Annotation, Path::new("UP006_2.py"); "UP006_2")] - #[test_case(Rule::NonPEP585Annotation, Path::new("UP006_3.py"); "UP006_3")] - #[test_case(Rule::NonPEP604Annotation, Path::new("UP007.py"); "UP007")] - #[test_case(Rule::SuperCallWithParameters, Path::new("UP008.py"); "UP008")] - #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_0.py"); "UP009_0")] - #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_1.py"); "UP009_1")] - #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_2.py"); "UP009_2")] - #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_3.py"); "UP009_3")] - #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_4.py"); "UP009_4")] - #[test_case(Rule::UnnecessaryFutureImport, Path::new("UP010.py"); "UP010")] - #[test_case(Rule::LRUCacheWithoutParameters, Path::new("UP011.py"); "UP011")] - #[test_case(Rule::UnnecessaryEncodeUTF8, Path::new("UP012.py"); "UP012")] - #[test_case(Rule::ConvertTypedDictFunctionalToClass, Path::new("UP013.py"); "UP013")] - #[test_case(Rule::ConvertNamedTupleFunctionalToClass, Path::new("UP014.py"); "UP014")] - #[test_case(Rule::RedundantOpenModes, Path::new("UP015.py"); "UP015")] - #[test_case(Rule::NativeLiterals, Path::new("UP018.py"); "UP018")] - #[test_case(Rule::TypingTextStrAlias, Path::new("UP019.py"); "UP019")] - #[test_case(Rule::OpenAlias, Path::new("UP020.py"); "UP020")] - #[test_case(Rule::ReplaceUniversalNewlines, Path::new("UP021.py"); "UP021")] - #[test_case(Rule::ReplaceStdoutStderr, Path::new("UP022.py"); "UP022")] - #[test_case(Rule::DeprecatedCElementTree, Path::new("UP023.py"); "UP023")] - #[test_case(Rule::OSErrorAlias, Path::new("UP024_0.py"); "UP024_0")] - #[test_case(Rule::OSErrorAlias, Path::new("UP024_1.py"); "UP024_1")] - #[test_case(Rule::OSErrorAlias, Path::new("UP024_2.py"); "UP024_2")] - #[test_case(Rule::OSErrorAlias, Path::new("UP024_3.py"); "UP024_3")] - #[test_case(Rule::OSErrorAlias, Path::new("UP024_4.py"); "UP024_4")] - #[test_case(Rule::UnicodeKindPrefix, Path::new("UP025.py"); "UP025")] - #[test_case(Rule::DeprecatedMockImport, Path::new("UP026.py"); "UP026")] - #[test_case(Rule::UnpackedListComprehension, Path::new("UP027.py"); "UP027")] - #[test_case(Rule::YieldInForLoop, Path::new("UP028_0.py"); "UP028_0")] - #[test_case(Rule::YieldInForLoop, Path::new("UP028_1.py"); "UP028_1")] - #[test_case(Rule::UnnecessaryBuiltinImport, Path::new("UP029.py"); "UP029")] - #[test_case(Rule::FormatLiterals, Path::new("UP030_0.py"); "UP030_0")] - #[test_case(Rule::FormatLiterals, Path::new("UP030_1.py"); "UP030_1")] - #[test_case(Rule::FormatLiterals, Path::new("UP030_2.py"); "UP030_2")] - #[test_case(Rule::PrintfStringFormatting, Path::new("UP031_0.py"); "UP031_0")] - #[test_case(Rule::PrintfStringFormatting, Path::new("UP031_1.py"); "UP031_1")] - #[test_case(Rule::FString, Path::new("UP032_0.py"); "UP032_0")] - #[test_case(Rule::FString, Path::new("UP032_1.py"); "UP032_1")] - #[test_case(Rule::FString, Path::new("UP032_2.py"); "UP032_2")] - #[test_case(Rule::LRUCacheWithMaxsizeNone, Path::new("UP033_0.py"); "UP033_0")] - #[test_case(Rule::LRUCacheWithMaxsizeNone, Path::new("UP033_1.py"); "UP033_1")] - #[test_case(Rule::ExtraneousParentheses, Path::new("UP034.py"); "UP034")] - #[test_case(Rule::DeprecatedImport, Path::new("UP035.py"); "UP035")] - #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_0.py"); "UP036_0")] - #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_1.py"); "UP036_1")] - #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_2.py"); "UP036_2")] - #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_3.py"); "UP036_3")] - #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_4.py"); "UP036_4")] - #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_5.py"); "UP036_5")] - #[test_case(Rule::QuotedAnnotation, Path::new("UP037.py"); "UP037")] - #[test_case(Rule::NonPEP604Isinstance, Path::new("UP038.py"); "UP038")] + #[test_case(Rule::UselessMetaclassType, Path::new("UP001.py"))] + #[test_case(Rule::TypeOfPrimitive, Path::new("UP003.py"))] + #[test_case(Rule::UselessObjectInheritance, Path::new("UP004.py"))] + #[test_case(Rule::DeprecatedUnittestAlias, Path::new("UP005.py"))] + #[test_case(Rule::NonPEP585Annotation, Path::new("UP006_0.py"))] + #[test_case(Rule::NonPEP585Annotation, Path::new("UP006_1.py"))] + #[test_case(Rule::NonPEP585Annotation, Path::new("UP006_2.py"))] + #[test_case(Rule::NonPEP585Annotation, Path::new("UP006_3.py"))] + #[test_case(Rule::NonPEP604Annotation, Path::new("UP007.py"))] + #[test_case(Rule::SuperCallWithParameters, Path::new("UP008.py"))] + #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_0.py"))] + #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_1.py"))] + #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_2.py"))] + #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_3.py"))] + #[test_case(Rule::UTF8EncodingDeclaration, Path::new("UP009_4.py"))] + #[test_case(Rule::UnnecessaryFutureImport, Path::new("UP010.py"))] + #[test_case(Rule::LRUCacheWithoutParameters, Path::new("UP011.py"))] + #[test_case(Rule::UnnecessaryEncodeUTF8, Path::new("UP012.py"))] + #[test_case(Rule::ConvertTypedDictFunctionalToClass, Path::new("UP013.py"))] + #[test_case(Rule::ConvertNamedTupleFunctionalToClass, Path::new("UP014.py"))] + #[test_case(Rule::RedundantOpenModes, Path::new("UP015.py"))] + #[test_case(Rule::NativeLiterals, Path::new("UP018.py"))] + #[test_case(Rule::TypingTextStrAlias, Path::new("UP019.py"))] + #[test_case(Rule::OpenAlias, Path::new("UP020.py"))] + #[test_case(Rule::ReplaceUniversalNewlines, Path::new("UP021.py"))] + #[test_case(Rule::ReplaceStdoutStderr, Path::new("UP022.py"))] + #[test_case(Rule::DeprecatedCElementTree, Path::new("UP023.py"))] + #[test_case(Rule::OSErrorAlias, Path::new("UP024_0.py"))] + #[test_case(Rule::OSErrorAlias, Path::new("UP024_1.py"))] + #[test_case(Rule::OSErrorAlias, Path::new("UP024_2.py"))] + #[test_case(Rule::OSErrorAlias, Path::new("UP024_3.py"))] + #[test_case(Rule::OSErrorAlias, Path::new("UP024_4.py"))] + #[test_case(Rule::UnicodeKindPrefix, Path::new("UP025.py"))] + #[test_case(Rule::DeprecatedMockImport, Path::new("UP026.py"))] + #[test_case(Rule::UnpackedListComprehension, Path::new("UP027.py"))] + #[test_case(Rule::YieldInForLoop, Path::new("UP028_0.py"))] + #[test_case(Rule::YieldInForLoop, Path::new("UP028_1.py"))] + #[test_case(Rule::UnnecessaryBuiltinImport, Path::new("UP029.py"))] + #[test_case(Rule::FormatLiterals, Path::new("UP030_0.py"))] + #[test_case(Rule::FormatLiterals, Path::new("UP030_1.py"))] + #[test_case(Rule::FormatLiterals, Path::new("UP030_2.py"))] + #[test_case(Rule::PrintfStringFormatting, Path::new("UP031_0.py"))] + #[test_case(Rule::PrintfStringFormatting, Path::new("UP031_1.py"))] + #[test_case(Rule::FString, Path::new("UP032_0.py"))] + #[test_case(Rule::FString, Path::new("UP032_1.py"))] + #[test_case(Rule::FString, Path::new("UP032_2.py"))] + #[test_case(Rule::LRUCacheWithMaxsizeNone, Path::new("UP033_0.py"))] + #[test_case(Rule::LRUCacheWithMaxsizeNone, Path::new("UP033_1.py"))] + #[test_case(Rule::ExtraneousParentheses, Path::new("UP034.py"))] + #[test_case(Rule::DeprecatedImport, Path::new("UP035.py"))] + #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_0.py"))] + #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_1.py"))] + #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_2.py"))] + #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_3.py"))] + #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_4.py"))] + #[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_5.py"))] + #[test_case(Rule::QuotedAnnotation, Path::new("UP037.py"))] + #[test_case(Rule::NonPEP604Isinstance, Path::new("UP038.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = path.to_string_lossy().to_string(); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/ruff/mod.rs b/crates/ruff/src/rules/ruff/mod.rs index d888933e00..40bc686e47 100644 --- a/crates/ruff/src/rules/ruff/mod.rs +++ b/crates/ruff/src/rules/ruff/mod.rs @@ -20,9 +20,9 @@ mod tests { use crate::test::{test_path, test_resource_path}; use crate::{assert_messages, settings}; - #[test_case(Rule::ExplicitFStringTypeConversion, Path::new("RUF010.py"); "RUF010")] - #[test_case(Rule::CollectionLiteralConcatenation, Path::new("RUF005.py"); "RUF005")] - #[test_case(Rule::AsyncioDanglingTask, Path::new("RUF006.py"); "RUF006")] + #[test_case(Rule::ExplicitFStringTypeConversion, Path::new("RUF010.py"))] + #[test_case(Rule::CollectionLiteralConcatenation, Path::new("RUF005.py"))] + #[test_case(Rule::AsyncioDanglingTask, Path::new("RUF006.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( @@ -167,8 +167,8 @@ mod tests { Ok(()) } - #[test_case(Rule::MutableDataclassDefault, Path::new("RUF008.py"); "RUF008")] - #[test_case(Rule::FunctionCallInDataclassDefaultArgument, Path::new("RUF009.py"); "RUF009")] + #[test_case(Rule::MutableDataclassDefault, Path::new("RUF008.py"))] + #[test_case(Rule::FunctionCallInDataclassDefaultArgument, Path::new("RUF009.py"))] fn mutable_defaults(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/crates/ruff/src/rules/tryceratops/mod.rs b/crates/ruff/src/rules/tryceratops/mod.rs index f4694b1d70..bf88fb825b 100644 --- a/crates/ruff/src/rules/tryceratops/mod.rs +++ b/crates/ruff/src/rules/tryceratops/mod.rs @@ -14,16 +14,16 @@ mod tests { use crate::test::test_path; use crate::{assert_messages, settings}; - #[test_case(Rule::RaiseVanillaClass, Path::new("TRY002.py"); "TRY002")] - #[test_case(Rule::RaiseVanillaArgs, Path::new("TRY003.py"); "TRY003")] - #[test_case(Rule::TypeCheckWithoutTypeError, Path::new("TRY004.py"); "TRY004")] - #[test_case(Rule::ReraiseNoCause, Path::new("TRY200.py"); "TRY200")] - #[test_case(Rule::VerboseRaise, Path::new("TRY201.py"); "TRY201")] - #[test_case(Rule::TryConsiderElse, Path::new("TRY300.py"); "TRY300")] - #[test_case(Rule::RaiseWithinTry , Path::new("TRY301.py"); "TRY301")] - #[test_case(Rule::UselessTryExcept , Path::new("TRY302.py"); "TRY302")] - #[test_case(Rule::ErrorInsteadOfException, Path::new("TRY400.py"); "TRY400")] - #[test_case(Rule::VerboseLogMessage, Path::new("TRY401.py"); "TRY401")] + #[test_case(Rule::RaiseVanillaClass, Path::new("TRY002.py"))] + #[test_case(Rule::RaiseVanillaArgs, Path::new("TRY003.py"))] + #[test_case(Rule::TypeCheckWithoutTypeError, Path::new("TRY004.py"))] + #[test_case(Rule::ReraiseNoCause, Path::new("TRY200.py"))] + #[test_case(Rule::VerboseRaise, Path::new("TRY201.py"))] + #[test_case(Rule::TryConsiderElse, Path::new("TRY300.py"))] + #[test_case(Rule::RaiseWithinTry, Path::new("TRY301.py"))] + #[test_case(Rule::UselessTryExcept, Path::new("TRY302.py"))] + #[test_case(Rule::ErrorInsteadOfException, Path::new("TRY400.py"))] + #[test_case(Rule::VerboseLogMessage, Path::new("TRY401.py"))] fn rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!("{}_{}", rule_code.as_ref(), path.to_string_lossy()); let diagnostics = test_path( diff --git a/scripts/add_rule.py b/scripts/add_rule.py index f803ec4224..b33b1cf57b 100755 --- a/scripts/add_rule.py +++ b/scripts/add_rule.py @@ -46,13 +46,7 @@ def main(*, name: str, prefix: str, code: str, linter: str) -> None: indent = get_indent(line) filestem = f"{prefix}{code}" if linter != "pylint" else snake_case(name) lines.append( - f'{indent}#[test_case(Rule::{name}, Path::new("{filestem}.py");' - f' "{prefix}{code}")]', - ) - lines.sort( - key=lambda line: line.split('Path::new("')[1] - if linter != "pylint" - else line.split(");")[1], + f'{indent}#[test_case(Rule::{name}, Path::new("{filestem}.py"))]', ) fp.write("\n".join(lines)) fp.write("\n")