Use direct links for all PEP 8 references (#5108)

This commit is contained in:
Charlie Marsh 2023-06-14 21:12:23 -04:00 committed by GitHub
parent 99486b38f4
commit c654280d84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 62 additions and 95 deletions

View file

@ -51,7 +51,7 @@ impl Violation for SingleLineImplicitStringConcatenation {
/// Checks for implicitly concatenated strings that span multiple lines.
///
/// ## Why is this bad?
/// For string literals that wrap across multiple lines, PEP 8 recommends
/// For string literals that wrap across multiple lines, [PEP 8] recommends
/// the use of implicit string concatenation within parentheses instead of
/// using a backslash for line continuation, as the former is more readable
/// than the latter.
@ -78,8 +78,7 @@ impl Violation for SingleLineImplicitStringConcatenation {
/// ## Options
/// - `flake8-implicit-str-concat.allow-multiline`
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#maximum-line-length)
/// [PEP 8]: https://peps.python.org/pep-0008/#maximum-line-length
#[violation]
pub struct MultiLineImplicitStringConcatenation;

View file

@ -40,7 +40,7 @@ use crate::registry::AsRule;
/// ```
///
/// ## References
/// - [Python: "isinstance"](https://docs.python.org/3/library/functions.html#isinstance)
/// - [Python documentation: `isinstance`](https://docs.python.org/3/library/functions.html#isinstance)
#[violation]
pub struct DuplicateIsinstanceCall {
name: Option<String>,

View file

@ -40,7 +40,7 @@ use super::fix_with;
/// ```
///
/// ## References
/// - [Python: "The with statement"](https://docs.python.org/3/reference/compound_stmts.html#the-with-statement)
/// - [Python documentation: The `with` statement](https://docs.python.org/3/reference/compound_stmts.html#the-with-statement)
#[violation]
pub struct MultipleWithStatements;

View file

@ -42,8 +42,7 @@ use ruff_python_ast::source_code::Locator;
/// ```
///
/// ## References
/// - [PEP 8](https://www.python.org/dev/peps/pep-0008/#programming-recommendations)
/// - [Python: "Exception hierarchy"](https://docs.python.org/3/library/exceptions.html#exception-hierarchy)
/// - [Python documentation: Exception hierarchy](https://docs.python.org/3/library/exceptions.html#exception-hierarchy)
/// - [Google Python Style Guide: "Exceptions"](https://google.github.io/styleguide/pyguide.html#24-exceptions)
#[violation]
pub struct BareExcept;

View file

@ -13,7 +13,7 @@ use crate::settings::Settings;
/// Checks for compound statements (multiple statements on the same line).
///
/// ## Why is this bad?
/// Per PEP 8, "compound statements are generally discouraged".
/// According to [PEP 8], "compound statements are generally discouraged".
///
/// ## Example
/// ```python
@ -25,9 +25,8 @@ use crate::settings::Settings;
/// if foo == "blah":
/// do_blah_thing()
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#other-recommendations)
/// [PEP 8]: https://peps.python.org/pep-0008/#other-recommendations
#[violation]
pub struct MultipleStatementsOnOneLineColon;
@ -42,7 +41,7 @@ impl Violation for MultipleStatementsOnOneLineColon {
/// Checks for multiline statements on one line.
///
/// ## Why is this bad?
/// Per PEP 8, including multi-clause statements on the same line is
/// According to [PEP 8], including multi-clause statements on the same line is
/// discouraged.
///
/// ## Example
@ -57,8 +56,7 @@ impl Violation for MultipleStatementsOnOneLineColon {
/// do_three()
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#other-recommendations)
/// [PEP 8]: https://peps.python.org/pep-0008/#other-recommendations
#[violation]
pub struct MultipleStatementsOnOneLineSemicolon;

View file

@ -10,7 +10,7 @@ use crate::checkers::ast::Checker;
/// Check for multiple imports on one line.
///
/// ## Why is this bad?
/// Per PEP 8, "imports should usually be on separate lines."
/// According to [PEP 8], "imports should usually be on separate lines."
///
/// ## Example
/// ```python
@ -23,8 +23,7 @@ use crate::checkers::ast::Checker;
/// import sys
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#imports)
/// [PEP 8]: https://peps.python.org/pep-0008/#imports
#[violation]
pub struct MultipleImportsOnOneLine;
@ -39,7 +38,7 @@ impl Violation for MultipleImportsOnOneLine {
/// Checks for imports that are not at the top of the file.
///
/// ## Why is this bad?
/// Per PEP 8, "imports are always put at the top of the file, just after any
/// According to [PEP 8], "imports are always put at the top of the file, just after any
/// module comments and docstrings, and before module globals and constants."
///
/// ## Example
@ -61,8 +60,7 @@ impl Violation for MultipleImportsOnOneLine {
/// a = 1
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#imports)
/// [PEP 8]: https://peps.python.org/pep-0008/#imports
#[violation]
pub struct ModuleImportNotAtTopOfFile;

View file

@ -33,8 +33,7 @@ use crate::registry::AsRule;
/// return 2 * x
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#programming-recommendations)
/// [PEP 8]: https://peps.python.org/pep-0008/#programming-recommendations
#[violation]
pub struct LambdaAssignment {
name: String,

View file

@ -30,7 +30,7 @@ impl EqCmpop {
/// Checks for comparisons to `None` which are not using the `is` operator.
///
/// ## Why is this bad?
/// Per PEP 8, "Comparisons to singletons like None should always be done with
/// According to [PEP 8], "Comparisons to singletons like None should always be done with
/// is or is not, never the equality operators."
///
/// ## Example
@ -47,8 +47,7 @@ impl EqCmpop {
/// pass
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#programming-recommendations)
/// [PEP 8]: https://peps.python.org/pep-0008/#programming-recommendations
#[violation]
pub struct NoneComparison(EqCmpop);
@ -75,7 +74,7 @@ impl AlwaysAutofixableViolation for NoneComparison {
/// Checks for comparisons to booleans which are not using the `is` operator.
///
/// ## Why is this bad?
/// Per PEP 8, "Comparisons to singletons like None should always be done with
/// According to [PEP 8], "Comparisons to singletons like None should always be done with
/// is or is not, never the equality operators."
///
/// ## Example
@ -94,8 +93,7 @@ impl AlwaysAutofixableViolation for NoneComparison {
/// pass
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#programming-recommendations)
/// [PEP 8]: https://peps.python.org/pep-0008/#programming-recommendations
#[violation]
pub struct TrueFalseComparison(bool, EqCmpop);

View file

@ -14,7 +14,7 @@ use super::{LogicalLine, Whitespace};
/// Checks for the use of extraneous whitespace after "(".
///
/// ## Why is this bad?
/// PEP 8 recommends the omission of whitespace in the following cases:
/// [PEP 8] recommends the omission of whitespace in the following cases:
/// - "Immediately inside parentheses, brackets or braces."
/// - "Immediately before a comma, semicolon, or colon."
///
@ -30,8 +30,7 @@ use super::{LogicalLine, Whitespace};
/// spam(ham[1], {eggs: 2})
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#pet-peeves)
/// [PEP 8]: https://peps.python.org/pep-0008/#pet-peeves
#[violation]
pub struct WhitespaceAfterOpenBracket {
symbol: char,
@ -54,7 +53,7 @@ impl AlwaysAutofixableViolation for WhitespaceAfterOpenBracket {
/// Checks for the use of extraneous whitespace before ")".
///
/// ## Why is this bad?
/// PEP 8 recommends the omission of whitespace in the following cases:
/// [PEP 8] recommends the omission of whitespace in the following cases:
/// - "Immediately inside parentheses, brackets or braces."
/// - "Immediately before a comma, semicolon, or colon."
///
@ -70,8 +69,7 @@ impl AlwaysAutofixableViolation for WhitespaceAfterOpenBracket {
/// spam(ham[1], {eggs: 2})
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#pet-peeves)
/// [PEP 8]: https://peps.python.org/pep-0008/#pet-peeves
#[violation]
pub struct WhitespaceBeforeCloseBracket {
symbol: char,
@ -94,7 +92,7 @@ impl AlwaysAutofixableViolation for WhitespaceBeforeCloseBracket {
/// Checks for the use of extraneous whitespace before ",", ";" or ":".
///
/// ## Why is this bad?
/// PEP 8 recommends the omission of whitespace in the following cases:
/// [PEP 8] recommends the omission of whitespace in the following cases:
/// - "Immediately inside parentheses, brackets or braces."
/// - "Immediately before a comma, semicolon, or colon."
///
@ -108,8 +106,7 @@ impl AlwaysAutofixableViolation for WhitespaceBeforeCloseBracket {
/// if x == 4: print(x, y); x, y = y, x
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#pet-peeves)
/// [PEP 8]: https://peps.python.org/pep-0008/#pet-peeves
#[violation]
pub struct WhitespaceBeforePunctuation {
symbol: char,

View file

@ -9,7 +9,7 @@ use super::LogicalLine;
/// Checks for indentation with a non-multiple of 4 spaces.
///
/// ## Why is this bad?
/// Per PEP 8, 4 spaces per indentation level should be preferred.
/// According to [PEP 8], 4 spaces per indentation level should be preferred.
///
/// ## Example
/// ```python
@ -23,8 +23,7 @@ use super::LogicalLine;
/// a = 1
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#indentation)
/// [PEP 8]: https://peps.python.org/pep-0008/#indentation
#[violation]
pub struct IndentationWithInvalidMultiple {
indent_size: usize,
@ -42,7 +41,7 @@ impl Violation for IndentationWithInvalidMultiple {
/// Checks for indentation of comments with a non-multiple of 4 spaces.
///
/// ## Why is this bad?
/// Per PEP 8, 4 spaces per indentation level should be preferred.
/// According to [PEP 8], 4 spaces per indentation level should be preferred.
///
/// ## Example
/// ```python
@ -56,8 +55,7 @@ impl Violation for IndentationWithInvalidMultiple {
/// # a = 1
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#indentation)
/// [PEP 8]: https://peps.python.org/pep-0008/#indentation
#[violation]
pub struct IndentationWithInvalidMultipleComment {
indent_size: usize,
@ -90,8 +88,7 @@ impl Violation for IndentationWithInvalidMultipleComment {
/// pass
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#indentation)
/// [PEP 8]: https://peps.python.org/pep-0008/#indentation
#[violation]
pub struct NoIndentedBlock;
@ -123,8 +120,7 @@ impl Violation for NoIndentedBlock {
/// pass
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#indentation)
/// [PEP 8]: https://peps.python.org/pep-0008/#indentation
#[violation]
pub struct NoIndentedBlockComment;
@ -153,8 +149,7 @@ impl Violation for NoIndentedBlockComment {
/// b = 2
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#indentation)
/// [PEP 8]: https://peps.python.org/pep-0008/#indentation
#[violation]
pub struct UnexpectedIndentation;
@ -183,8 +178,7 @@ impl Violation for UnexpectedIndentation {
/// # b = 2
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#indentation)
/// [PEP 8]: https://peps.python.org/pep-0008/#indentation
#[violation]
pub struct UnexpectedIndentationComment;
@ -199,7 +193,7 @@ impl Violation for UnexpectedIndentationComment {
/// Checks for over-indented code.
///
/// ## Why is this bad?
/// Per PEP 8, 4 spaces per indentation level should be preferred. Increased
/// According to [PEP 8], 4 spaces per indentation level should be preferred. Increased
/// indentation can lead to inconsistent formatting, which can hurt
/// readability.
///
@ -215,8 +209,7 @@ impl Violation for UnexpectedIndentationComment {
/// pass
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#indentation)
/// [PEP 8]: https://peps.python.org/pep-0008/#indentation
#[violation]
pub struct OverIndented {
is_comment: bool,

View file

@ -12,7 +12,7 @@ use super::{LogicalLine, Whitespace};
/// Checks for extraneous tabs before an operator.
///
/// ## Why is this bad?
/// Per PEP 8, operators should be surrounded by at most a single space on either
/// According to [PEP 8], operators should be surrounded by at most a single space on either
/// side.
///
/// ## Example
@ -25,8 +25,7 @@ use super::{LogicalLine, Whitespace};
/// a = 12 + 3
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#whitespace-in-expressions-and-statements)
/// [PEP 8]: https://peps.python.org/pep-0008/#whitespace-in-expressions-and-statements
#[violation]
pub struct TabBeforeOperator;
@ -41,7 +40,7 @@ impl Violation for TabBeforeOperator {
/// Checks for extraneous whitespace before an operator.
///
/// ## Why is this bad?
/// Per PEP 8, operators should be surrounded by at most a single space on either
/// According to [PEP 8], operators should be surrounded by at most a single space on either
/// side.
///
/// ## Example
@ -54,8 +53,7 @@ impl Violation for TabBeforeOperator {
/// a = 12 + 3
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#whitespace-in-expressions-and-statements)
/// [PEP 8]: https://peps.python.org/pep-0008/#whitespace-in-expressions-and-statements
#[violation]
pub struct MultipleSpacesBeforeOperator;
@ -70,7 +68,7 @@ impl Violation for MultipleSpacesBeforeOperator {
/// Checks for extraneous tabs after an operator.
///
/// ## Why is this bad?
/// Per PEP 8, operators should be surrounded by at most a single space on either
/// According to [PEP 8], operators should be surrounded by at most a single space on either
/// side.
///
/// ## Example
@ -83,8 +81,7 @@ impl Violation for MultipleSpacesBeforeOperator {
/// a = 12 + 3
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#whitespace-in-expressions-and-statements)
/// [PEP 8]: https://peps.python.org/pep-0008/#whitespace-in-expressions-and-statements
#[violation]
pub struct TabAfterOperator;
@ -99,7 +96,7 @@ impl Violation for TabAfterOperator {
/// Checks for extraneous whitespace after an operator.
///
/// ## Why is this bad?
/// Per PEP 8, operators should be surrounded by at most a single space on either
/// According to [PEP 8], operators should be surrounded by at most a single space on either
/// side.
///
/// ## Example
@ -112,8 +109,7 @@ impl Violation for TabAfterOperator {
/// a = 12 + 3
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#whitespace-in-expressions-and-statements)
/// [PEP 8]: https://peps.python.org/pep-0008/#whitespace-in-expressions-and-statements
#[violation]
pub struct MultipleSpacesAfterOperator;

View file

@ -59,8 +59,7 @@ impl Violation for TooFewSpacesBeforeInlineComment {
/// x = x + 1 # Increment x
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#comments)
/// [PEP 8]: https://peps.python.org/pep-0008/#comments
#[violation]
pub struct NoSpaceAfterInlineComment;
@ -92,8 +91,7 @@ impl Violation for NoSpaceAfterInlineComment {
/// # \xa0- Block comment list
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#comments)
/// [PEP 8]: https://peps.python.org/pep-0008/#comments
#[violation]
pub struct NoSpaceAfterBlockComment;
@ -125,8 +123,7 @@ impl Violation for NoSpaceAfterBlockComment {
/// # \xa0- Block comment list
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#comments)
/// [PEP 8]: https://peps.python.org/pep-0008/#comments
#[violation]
pub struct MultipleLeadingHashesForBlockComment;

View file

@ -11,7 +11,7 @@ use crate::settings::Settings;
/// Checks for superfluous trailing whitespace.
///
/// ## Why is this bad?
/// Per PEP 8, "avoid trailing whitespace anywhere. Because its usually
/// According to [PEP 8], "avoid trailing whitespace anywhere. Because its usually
/// invisible, it can be confusing"
///
/// ## Example
@ -24,8 +24,7 @@ use crate::settings::Settings;
/// spam(1)\n#
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#other-recommendations)
/// [PEP 8]: https://peps.python.org/pep-0008/#other-recommendations
#[violation]
pub struct TrailingWhitespace;
@ -44,7 +43,7 @@ impl AlwaysAutofixableViolation for TrailingWhitespace {
/// Checks for superfluous whitespace in blank lines.
///
/// ## Why is this bad?
/// Per PEP 8, "avoid trailing whitespace anywhere. Because its usually
/// According to [PEP 8], "avoid trailing whitespace anywhere. Because its usually
/// invisible, it can be confusing"
///
/// ## Example
@ -57,8 +56,7 @@ impl AlwaysAutofixableViolation for TrailingWhitespace {
/// class Foo(object):\n\n bang = 12
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#other-recommendations)
/// [PEP 8]: https://peps.python.org/pep-0008/#other-recommendations
#[violation]
pub struct BlankLineWithWhitespace;

View file

@ -51,7 +51,7 @@ impl Violation for ImportShadowedByLoopVar {
/// ## Why is this bad?
/// Wildcard imports (e.g., `from module import *`) make it hard to determine
/// which symbols are available in the current namespace, and from which module
/// they were imported.
/// they were imported. They're also discouraged by [PEP 8].
///
/// ## Example
/// ```python
@ -71,8 +71,7 @@ impl Violation for ImportShadowedByLoopVar {
/// return pi * radius**2
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#imports)
/// [PEP 8]: https://peps.python.org/pep-0008/#imports
#[violation]
pub struct UndefinedLocalWithImportStar {
pub(crate) name: String,
@ -110,7 +109,7 @@ impl Violation for UndefinedLocalWithImportStar {
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#module-level-dunder-names)
/// - [Python documentation: Future statements](https://docs.python.org/3/reference/simple_stmts.html#future)
#[violation]
pub struct LateFutureImport;
@ -155,9 +154,6 @@ impl Violation for LateFutureImport {
/// def area(radius):
/// return pi * radius**2
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#imports)
#[violation]
pub struct UndefinedLocalWithImportStarUsage {
pub(crate) name: String,
@ -183,8 +179,9 @@ impl Violation for UndefinedLocalWithImportStarUsage {
/// The use of wildcard imports outside of the module namespace (e.g., within
/// functions) can lead to confusion, as the import can shadow local variables.
///
/// Though wildcard imports are discouraged, when necessary, they should be placed
/// in the module namespace (i.e., at the top-level of a module).
/// Though wildcard imports are discouraged by [PEP 8], when necessary, they
/// should be placed in the module namespace (i.e., at the top-level of a
/// module).
///
/// ## Example
/// ```python
@ -201,8 +198,7 @@ impl Violation for UndefinedLocalWithImportStarUsage {
/// ...
/// ```
///
/// ## References
/// - [PEP 8](https://peps.python.org/pep-0008/#imports)
/// [PEP 8]: https://peps.python.org/pep-0008/#imports
#[violation]
pub struct UndefinedLocalWithNestedImportStarUsage {
pub(crate) name: String,

View file

@ -12,8 +12,9 @@ use crate::rules::pylint::settings::ConstantType;
/// comparisons.
///
/// ## Why is this bad?
/// The use of "magic" can make code harder to read and maintain, as readers
/// will have to infer the meaning of the value from the context.
/// The use of "magic" values can make code harder to read and maintain, as
/// readers will have to infer the meaning of the value from the context.
/// Such values are discouraged by [PEP 8].
///
/// For convenience, this rule excludes a variety of common values from the
/// "magic" value definition, such as `0`, `1`, `""`, and `"__main__"`.
@ -33,9 +34,7 @@ use crate::rules::pylint::settings::ConstantType;
/// return price * (1 - DISCOUNT_RATE)
/// ```
///
/// ## References
/// - [Wikipedia](https://en.wikipedia.org/wiki/Magic_number_(programming)#Unnamed_numerical_constants)
/// - [PEP 8](https://peps.python.org/pep-0008/#constants)
/// [PEP 8]: https://peps.python.org/pep-0008/#constants
#[violation]
pub struct MagicValueComparison {
value: String,

View file

@ -35,7 +35,7 @@ use crate::registry::Rule;
///
/// ## References
/// - [PEP 563](https://peps.python.org/pep-0563/)
/// - [Python documentation: `__future__` - Future statement definitions](https://docs.python.org/3/library/__future__.html#module-__future__)
/// - [Python documentation: `__future__`](https://docs.python.org/3/library/__future__.html#module-__future__)
#[violation]
pub struct QuotedAnnotation;