diff --git a/README.md b/README.md index 2e621f3b47..828f33a863 100644 --- a/README.md +++ b/README.md @@ -409,7 +409,7 @@ For more, see [pydocstyle](https://pypi.org/project/pydocstyle/6.1.1/) on PyPI. | D400 | EndsInPeriod | First line should end with a period | | | D402 | NoSignature | First line should not be the function's signature | | | D403 | FirstLineCapitalized | First word of the first line should be properly capitalized | | -| D404 | NoThisPrefix | First word of the docstring should not be 'This' | | +| D404 | NoThisPrefix | First word of the docstring should not be "This" | | | D405 | CapitalizeSectionName | Section name should be properly capitalized ("returns") | 🛠 | | D406 | NewLineAfterSectionName | Section name should end with a newline ("Returns") | 🛠 | | D407 | DashedUnderlineAfterSection | Missing dashed underline after section ("Returns") | 🛠 | @@ -440,7 +440,7 @@ For more, see [pyupgrade](https://pypi.org/project/pyupgrade/3.2.0/) on PyPI. | U006 | UsePEP585Annotation | Use `list` instead of `List` for type annotations | 🛠 | | U007 | UsePEP604Annotation | Use `X \| Y` for type annotations | 🛠 | | U008 | SuperCallWithParameters | Use `super()` instead of `super(__class__, self)` | 🛠 | -| U009 | PEP3120UnnecessaryCodingComment | utf-8 encoding declaration is unnecessary | 🛠 | +| U009 | PEP3120UnnecessaryCodingComment | UTF-8 encoding declaration is unnecessary | 🛠 | | U010 | UnnecessaryFutureImport | Unnecessary `__future__` import `...` for target Python version | 🛠 | | U011 | UnnecessaryLRUCacheParams | Unnecessary parameters to `functools.lru_cache` | 🛠 | | U012 | UnnecessaryEncodeUTF8 | Unnecessary call to `encode` as UTF-8 | 🛠 | @@ -476,9 +476,9 @@ For more, see [flake8-bandit](https://pypi.org/project/flake8-bandit/4.1.1/) on | S101 | AssertUsed | Use of `assert` detected | | | S102 | ExecUsed | Use of `exec` detected | | | S104 | HardcodedBindAllInterfaces | Possible binding to all interfaces | | -| S105 | HardcodedPasswordString | Possible hardcoded password: `'...'` | | -| S106 | HardcodedPasswordFuncArg | Possible hardcoded password: `'...'` | | -| S107 | HardcodedPasswordDefault | Possible hardcoded password: `'...'` | | +| S105 | HardcodedPasswordString | Possible hardcoded password: `"..."` | | +| S106 | HardcodedPasswordFuncArg | Possible hardcoded password: `"..."` | | +| S107 | HardcodedPasswordDefault | Possible hardcoded password: `"..."` | | ### flake8-comprehensions @@ -509,25 +509,25 @@ For more, see [flake8-bugbear](https://pypi.org/project/flake8-bugbear/22.10.27/ | Code | Name | Message | Fix | | ---- | ---- | ------- | --- | -| B002 | UnaryPrefixIncrement | Python does not support the unary prefix increment. | | -| B003 | AssignmentToOsEnviron | Assigning to `os.environ` doesn't clear the environment. | | +| B002 | UnaryPrefixIncrement | Python does not support the unary prefix increment | | +| B003 | AssignmentToOsEnviron | Assigning to `os.environ` doesn't clear the environment | | | B004 | UnreliableCallableCheck | Using `hasattr(x, '__call__')` to test if x is callable is unreliable. Use `callable(x)` for consistent results. | | -| B005 | StripWithMultiCharacters | Using `.strip()` with multi-character strings is misleading the reader. | | -| B006 | MutableArgumentDefault | Do not use mutable data structures for argument defaults. | | -| B007 | UnusedLoopControlVariable | Loop control variable `i` not used within the loop body. | 🛠 | +| B005 | StripWithMultiCharacters | Using `.strip()` with multi-character strings is misleading the reader | | +| B006 | MutableArgumentDefault | Do not use mutable data structures for argument defaults | | +| B007 | UnusedLoopControlVariable | Loop control variable `i` not used within the loop body | 🛠 | | B008 | FunctionCallArgumentDefault | Do not perform function call in argument defaults | | -| B009 | GetAttrWithConstant | Do not call `getattr` with a constant attribute value, it is not any safer than normal property access. | 🛠 | -| B010 | SetAttrWithConstant | Do not call `setattr` with a constant attribute value, it is not any safer than normal property access. | | +| B009 | GetAttrWithConstant | Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. | 🛠 | +| B010 | SetAttrWithConstant | Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. | | | B011 | DoNotAssertFalse | Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` | 🛠 | | B013 | RedundantTupleInExceptionHandler | A length-one tuple literal is redundant. Write `except ValueError:` instead of `except (ValueError,):`. | | | B014 | DuplicateHandlerException | Exception handler with duplicate exception: `ValueError` | 🛠 | | B015 | UselessComparison | Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. | | | B016 | CannotRaiseLiteral | Cannot raise a literal. Did you intend to return it or raise an Exception? | | -| B017 | NoAssertRaisesException | `assertRaises(Exception):` should be considered evil. | | +| B017 | NoAssertRaisesException | `assertRaises(Exception):` should be considered evil | | | B018 | UselessExpression | Found useless expression. Either assign it to a variable or remove it. | | -| B019 | CachedInstanceMethod | Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks. | | +| B019 | CachedInstanceMethod | Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks | | | B025 | DuplicateTryBlockException | try-except block with duplicate exception `Exception` | | -| B026 | StarArgUnpackingAfterKeywordArg | Star-arg unpacking after a keyword argument is strongly discouraged. | | +| B026 | StarArgUnpackingAfterKeywordArg | Star-arg unpacking after a keyword argument is strongly discouraged | | ### flake8-builtins diff --git a/src/checks.rs b/src/checks.rs index cdf394f752..2061100e96 100644 --- a/src/checks.rs +++ b/src/checks.rs @@ -1236,7 +1236,7 @@ impl CheckKind { CheckKind::BreakOutsideLoop => "`break` outside loop".to_string(), CheckKind::ContinueOutsideLoop => "`continue` not properly in loop".to_string(), CheckKind::DefaultExceptNotLast => { - "An `except:` block as not the last exception handler".to_string() + "An `except` block as not the last exception handler".to_string() } CheckKind::DoNotAssignLambda => { "Do not assign a lambda expression, use a def".to_string() @@ -1373,17 +1373,17 @@ impl CheckKind { `+(+(n))`, which equals `n`. You meant `n += 1`." .to_string(), CheckKind::AssignmentToOsEnviron => { - "Assigning to `os.environ` doesn't clear the environment.".to_string() + "Assigning to `os.environ` doesn't clear the environment".to_string() } CheckKind::UnreliableCallableCheck => " Using `hasattr(x, '__call__')` to test if x \ is callable is unreliable. Use `callable(x)` \ for consistent results." .to_string(), - CheckKind::StripWithMultiCharacters => "Using `.strip()` with multi-character strings \ - is misleading the reader." - .to_string(), + CheckKind::StripWithMultiCharacters => { + "Using `.strip()` with multi-character strings is misleading the reader".to_string() + } CheckKind::MutableArgumentDefault => { - "Do not use mutable data structures for argument defaults.".to_string() + "Do not use mutable data structures for argument defaults".to_string() } CheckKind::UnusedLoopControlVariable(name) => format!( "Loop control variable `{name}` not used within the loop body. If this is \ @@ -1397,11 +1397,11 @@ impl CheckKind { } } CheckKind::GetAttrWithConstant => "Do not call `getattr` with a constant attribute \ - value, it is not any safer than normal property \ + value. It is not any safer than normal property \ access." .to_string(), CheckKind::SetAttrWithConstant => "Do not call `setattr` with a constant attribute \ - value, it is not any safer than normal property \ + value. It is not any safer than normal property \ access." .to_string(), CheckKind::DoNotAssertFalse => "Do not `assert False` (`python -O` removes these \ @@ -1409,8 +1409,8 @@ impl CheckKind { .to_string(), CheckKind::RedundantTupleInExceptionHandler(name) => { format!( - "A length-one tuple literal is redundant. Write `except {name}:` instead of \ - `except ({name},):`." + "A length-one tuple literal is redundant. Write `except {name}` instead of \ + `except ({name},)`." ) } CheckKind::UselessComparison => "Pointless comparison. This comparison does nothing \ @@ -1430,7 +1430,7 @@ impl CheckKind { } } CheckKind::NoAssertRaisesException => { - "`assertRaises(Exception):` should be considered evil. It can lead to your test \ + "`assertRaises(Exception)` should be considered evil. It can lead to your test \ passing even if the code being tested is never executed due to a typo. Either \ assert for a more specific exception (builtin or custom), use \ `assertRaisesRegex`, or use the context manager form of `assertRaises`." @@ -1440,16 +1440,15 @@ impl CheckKind { "Found useless expression. Either assign it to a variable or remove it.".to_string() } CheckKind::CachedInstanceMethod => "Use of `functools.lru_cache` or `functools.cache` \ - on methods can lead to memory leaks." + on methods can lead to memory leaks" .to_string(), CheckKind::DuplicateTryBlockException(name) => { format!("try-except block with duplicate exception `{name}`") } CheckKind::StarArgUnpackingAfterKeywordArg => { - "Star-arg unpacking after a keyword argument is strongly discouraged, because it \ - only works when the keyword parameter is declared after all parameters supplied \ - by the unpacked sequence, and this change of ordering can surprise and mislead \ - readers." + "Star-arg unpacking after a keyword argument is strongly discouraged. It only \ + works when the keyword parameter is declared after all parameters supplied by the \ + unpacked sequence, and this change of ordering can surprise and mislead readers." .to_string() } // flake8-comprehensions @@ -1707,7 +1706,7 @@ impl CheckKind { CheckKind::PublicNestedClass => "Missing docstring in public nested class".to_string(), CheckKind::PublicInit => "Missing docstring in `__init__`".to_string(), CheckKind::NoThisPrefix => { - "First word of the docstring should not be 'This'".to_string() + "First word of the docstring should not be \"This\"".to_string() } CheckKind::SkipDocstring => { "Function decorated with `@overload` shouldn't contain a docstring".to_string() @@ -1815,7 +1814,7 @@ impl CheckKind { format!("Exception name `{name}` should be named with an Error suffix") } CheckKind::PEP3120UnnecessaryCodingComment => { - "utf-8 encoding declaration is unnecessary".to_string() + "UTF-8 encoding declaration is unnecessary".to_string() } // isort CheckKind::UnsortedImports => "Import block is un-sorted or un-formatted".to_string(), @@ -1826,13 +1825,13 @@ impl CheckKind { "Possible binding to all interfaces".to_string() } CheckKind::HardcodedPasswordString(string) => { - format!("Possible hardcoded password: `'{string}'`") + format!("Possible hardcoded password: `\"{string}\"`") } CheckKind::HardcodedPasswordFuncArg(string) => { - format!("Possible hardcoded password: `'{string}'`") + format!("Possible hardcoded password: `\"{string}\"`") } CheckKind::HardcodedPasswordDefault(string) => { - format!("Possible hardcoded password: `'{string}'`") + format!("Possible hardcoded password: `\"{string}\"`") } // Ruff CheckKind::AmbiguousUnicodeCharacterString(confusable, representant) => { @@ -1878,16 +1877,16 @@ impl CheckKind { pub fn summary(&self) -> String { match self { CheckKind::UnaryPrefixIncrement => { - "Python does not support the unary prefix increment.".to_string() + "Python does not support the unary prefix increment".to_string() } CheckKind::UnusedLoopControlVariable(name) => { - format!("Loop control variable `{name}` not used within the loop body.") + format!("Loop control variable `{name}` not used within the loop body") } CheckKind::NoAssertRaisesException => { - "`assertRaises(Exception):` should be considered evil.".to_string() + "`assertRaises(Exception)` should be considered evil".to_string() } CheckKind::StarArgUnpackingAfterKeywordArg => { - "Star-arg unpacking after a keyword argument is strongly discouraged.".to_string() + "Star-arg unpacking after a keyword argument is strongly discouraged".to_string() } _ => self.body(), }