From c654280d84c9cb7c6aec24f3a3f77ebafbf67cbd Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 14 Jun 2023 21:12:23 -0400 Subject: [PATCH] Use direct links for all PEP 8 references (#5108) --- .../rules/implicit.rs | 5 ++-- .../flake8_simplify/rules/ast_bool_op.rs | 2 +- .../rules/flake8_simplify/rules/ast_with.rs | 2 +- .../rules/pycodestyle/rules/bare_except.rs | 3 +-- .../pycodestyle/rules/compound_statements.rs | 12 ++++----- .../src/rules/pycodestyle/rules/imports.rs | 10 +++---- .../pycodestyle/rules/lambda_assignment.rs | 3 +-- .../pycodestyle/rules/literal_comparisons.rs | 10 +++---- .../logical_lines/extraneous_whitespace.rs | 15 +++++------ .../rules/logical_lines/indentation.rs | 27 +++++++------------ .../logical_lines/space_around_operator.rs | 20 ++++++-------- .../whitespace_before_comment.rs | 9 +++---- .../pycodestyle/rules/trailing_whitespace.rs | 10 +++---- .../ruff/src/rules/pyflakes/rules/imports.rs | 18 +++++-------- .../pylint/rules/magic_value_comparison.rs | 9 +++---- .../pyupgrade/rules/quoted_annotation.rs | 2 +- 16 files changed, 62 insertions(+), 95 deletions(-) diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/rules/implicit.rs b/crates/ruff/src/rules/flake8_implicit_str_concat/rules/implicit.rs index 1d7c32a0c7..69def84c39 100644 --- a/crates/ruff/src/rules/flake8_implicit_str_concat/rules/implicit.rs +++ b/crates/ruff/src/rules/flake8_implicit_str_concat/rules/implicit.rs @@ -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; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs index 7a21a13ead..4c7fdd4cb0 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs @@ -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, diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_with.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_with.rs index 7e1cc3a43d..72dbce6b09 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_with.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_with.rs @@ -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; diff --git a/crates/ruff/src/rules/pycodestyle/rules/bare_except.rs b/crates/ruff/src/rules/pycodestyle/rules/bare_except.rs index 42adebdc54..0b9eee1598 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/bare_except.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/bare_except.rs @@ -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; diff --git a/crates/ruff/src/rules/pycodestyle/rules/compound_statements.rs b/crates/ruff/src/rules/pycodestyle/rules/compound_statements.rs index 908e1c07f9..6f095d8272 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/compound_statements.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/compound_statements.rs @@ -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; diff --git a/crates/ruff/src/rules/pycodestyle/rules/imports.rs b/crates/ruff/src/rules/pycodestyle/rules/imports.rs index 61e163354c..4504ade301 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/imports.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/imports.rs @@ -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; diff --git a/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs b/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs index 8c17df32ec..99ffe1f766 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs @@ -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, diff --git a/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs b/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs index 8f4eaff3bc..adf7933c32 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs @@ -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); diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs index d8a3512cf7..ca4b1ed3d0 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs @@ -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, diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/indentation.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/indentation.rs index 9f7f3b652b..6fa4cb316c 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/indentation.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/indentation.rs @@ -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, diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs index 5c111773de..d7ea88a803 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs @@ -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; diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs index 3a42136dcb..dd2e4e4271 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs @@ -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; diff --git a/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs b/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs index f4841a385d..ff7082c9c7 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs @@ -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 it’s usually +/// According to [PEP 8], "avoid trailing whitespace anywhere. Because it’s 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 it’s usually +/// According to [PEP 8], "avoid trailing whitespace anywhere. Because it’s 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; diff --git a/crates/ruff/src/rules/pyflakes/rules/imports.rs b/crates/ruff/src/rules/pyflakes/rules/imports.rs index 220925b709..b53b9394f1 100644 --- a/crates/ruff/src/rules/pyflakes/rules/imports.rs +++ b/crates/ruff/src/rules/pyflakes/rules/imports.rs @@ -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, diff --git a/crates/ruff/src/rules/pylint/rules/magic_value_comparison.rs b/crates/ruff/src/rules/pylint/rules/magic_value_comparison.rs index 60a6a8e4c2..c337641c79 100644 --- a/crates/ruff/src/rules/pylint/rules/magic_value_comparison.rs +++ b/crates/ruff/src/rules/pylint/rules/magic_value_comparison.rs @@ -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, diff --git a/crates/ruff/src/rules/pyupgrade/rules/quoted_annotation.rs b/crates/ruff/src/rules/pyupgrade/rules/quoted_annotation.rs index c14ad79904..12988fecee 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/quoted_annotation.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/quoted_annotation.rs @@ -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;