Skip to content

Commit d1ef418

Browse files
sbrugmanMichaReiserAlexWaygood
authored
Docs: tweak rules documentation (#14180)
Co-authored-by: Micha Reiser <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
1 parent 272d24b commit d1ef418

File tree

56 files changed

+164
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+164
-98
lines changed

crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl Violation for MissingReturnTypeClassMethod {
469469
/// ```
470470
///
471471
/// ## References
472-
/// - [PEP 484](https://www.python.org/dev/peps/pep-0484/#the-any-type)
472+
/// - [Typing spec: `Any`](https://typing.readthedocs.io/en/latest/spec/special-types.html#any)
473473
/// - [Python documentation: `typing.Any`](https://docs.python.org/3/library/typing.html#typing.Any)
474474
/// - [Mypy documentation: The Any type](https://mypy.readthedocs.io/en/stable/kinds_of_types.html#the-any-type)
475475
#[violation]

crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_imports.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@ use crate::checkers::ast::Checker;
1010
use crate::registry::AsRule;
1111

1212
/// ## What it does
13-
/// Checks for imports of the`telnetlib` module.
13+
/// Checks for imports of the `telnetlib` module.
1414
///
1515
/// ## Why is this bad?
16-
/// Telnet is considered insecure. Instead, use SSH or another encrypted
16+
/// Telnet is considered insecure. It is deprecated since version 3.11, and
17+
/// was removed in version 3.13. Instead, use SSH or another encrypted
1718
/// protocol.
1819
///
1920
/// ## Example
2021
/// ```python
2122
/// import telnetlib
2223
/// ```
24+
///
25+
/// ## References
26+
/// - [Python documentation: `telnetlib` - Telnet client](https://docs.python.org/3.12/library/telnetlib.html#module-telnetlib)
27+
/// - [PEP 594: `telnetlib`](https://peps.python.org/pep-0594/#telnetlib)
2328
#[violation]
2429
pub struct SuspiciousTelnetlibImport;
2530

@@ -41,6 +46,9 @@ impl Violation for SuspiciousTelnetlibImport {
4146
/// ```python
4247
/// import ftplib
4348
/// ```
49+
///
50+
/// ## References
51+
/// - [Python documentation: `ftplib` - FTP protocol client](https://docs.python.org/3/library/ftplib.html)
4452
#[violation]
4553
pub struct SuspiciousFtplibImport;
4654

@@ -63,8 +71,9 @@ impl Violation for SuspiciousFtplibImport {
6371
/// ```python
6472
/// import pickle
6573
/// ```
74+
///
6675
/// ## References
67-
/// - [Python Docs](https://docs.python.org/3/library/pickle.html)
76+
/// - [Python documentation: `pickle` — Python object serialization](https://docs.python.org/3/library/pickle.html)
6877
#[violation]
6978
pub struct SuspiciousPickleImport;
7079

crates/ruff_linter/src/rules/flake8_bandit/rules/tarfile_unsafe_members.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use ruff_text_size::Ranged;
3333
///
3434
/// ## References
3535
/// - [Common Weakness Enumeration: CWE-22](https://cwe.mitre.org/data/definitions/22.html)
36-
/// - [Python Documentation: `TarFile.extractall`](https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractall)
37-
/// - [Python Documentation: Extraction filters](https://docs.python.org/3/library/tarfile.html#tarfile-extraction-filter)
36+
/// - [Python documentation: `TarFile.extractall`](https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractall)
37+
/// - [Python documentation: Extraction filters](https://docs.python.org/3/library/tarfile.html#tarfile-extraction-filter)
3838
///
3939
/// [PEP 706]: https://peps.python.org/pep-0706/#backporting-forward-compatibility
4040
#[violation]

crates/ruff_linter/src/rules/flake8_blind_except/rules/blind_except.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ use crate::checkers::ast::Checker;
6060
/// ## References
6161
/// - [Python documentation: The `try` statement](https://docs.python.org/3/reference/compound_stmts.html#the-try-statement)
6262
/// - [Python documentation: Exception hierarchy](https://docs.python.org/3/library/exceptions.html#exception-hierarchy)
63-
/// - [PEP8 Programming Recommendations on bare `except`](https://peps.python.org/pep-0008/#programming-recommendations)
63+
/// - [PEP 8: Programming Recommendations on bare `except`](https://peps.python.org/pep-0008/#programming-recommendations)
6464
#[violation]
6565
pub struct BlindExcept {
6666
name: String,

crates/ruff_linter/src/rules/flake8_bugbear/rules/abstract_base_class.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl Violation for AbstractBaseClassWithoutAbstractMethod {
8888
/// ```
8989
///
9090
/// ## References
91-
/// - [Python documentation: abc](https://docs.python.org/3/library/abc.html)
91+
/// - [Python documentation: `abc`](https://docs.python.org/3/library/abc.html)
9292
#[violation]
9393
pub struct EmptyMethodWithoutAbstractDecorator {
9494
name: String,

crates/ruff_linter/src/rules/flake8_bugbear/rules/f_string_docstring.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use crate::checkers::ast::Checker;
2828
/// ```
2929
///
3030
/// ## References
31-
/// - [PEP 257](https://peps.python.org/pep-0257/)
31+
/// - [PEP 257 – Docstring Conventions](https://peps.python.org/pep-0257/)
3232
/// - [Python documentation: Formatted string literals](https://docs.python.org/3/reference/lexical_analysis.html#f-strings)
3333
#[violation]
3434
pub struct FStringDocstring;

crates/ruff_linter/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use crate::checkers::ast::Checker;
4040
///
4141
/// ## References
4242
/// - [The Hitchhiker's Guide to Python: Late Binding Closures](https://docs.python-guide.org/writing/gotchas/#late-binding-closures)
43-
/// - [Python documentation: functools.partial](https://docs.python.org/3/library/functools.html#functools.partial)
43+
/// - [Python documentation: `functools.partial`](https://docs.python.org/3/library/functools.html#functools.partial)
4444
#[violation]
4545
pub struct FunctionUsesLoopVariable {
4646
name: String,

crates/ruff_linter/src/rules/flake8_bugbear/rules/no_explicit_stacklevel.rs

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ use crate::checkers::ast::Checker;
2626
/// ```python
2727
/// warnings.warn("This is a warning", stacklevel=2)
2828
/// ```
29+
///
30+
/// ## References
31+
/// - [Python documentation: `warnings.warn`](https://docs.python.org/3/library/warnings.html#warnings.warn)
2932
#[violation]
3033
pub struct NoExplicitStacklevel;
3134

crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_contextlib_suppress.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::checkers::ast::Checker;
3535
/// ```
3636
///
3737
/// ## References
38-
/// - [Python documentation: contextlib.suppress](https://docs.python.org/3/library/contextlib.html#contextlib.suppress)
38+
/// - [Python documentation: `contextlib.suppress`](https://docs.python.org/3/library/contextlib.html#contextlib.suppress)
3939
#[violation]
4040
pub struct UselessContextlibSuppress;
4141

crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_dict_comprehension_for_iterable.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ use crate::checkers::ast::Checker;
3030
/// dict.fromkeys(iterable)
3131
/// dict.fromkeys(iterable, 1)
3232
/// ```
33+
///
34+
/// ## References
35+
/// - [Python documentation: `dict.fromkeys`](https://docs.python.org/3/library/stdtypes.html#dict.fromkeys)
3336
#[violation]
3437
pub struct UnnecessaryDictComprehensionForIterable {
3538
is_value_none_literal: bool,
@@ -53,7 +56,7 @@ impl Violation for UnnecessaryDictComprehensionForIterable {
5356
}
5457
}
5558

56-
/// RUF025
59+
/// C420
5760
pub(crate) fn unnecessary_dict_comprehension_for_iterable(
5861
checker: &mut Checker,
5962
dict_comp: &ast::ExprDictComp,

crates/ruff_linter/src/rules/flake8_gettext/rules/f_string_in_gettext_func_call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::checkers::ast::Checker;
3939
/// ```
4040
///
4141
/// ## References
42-
/// - [Python documentation: gettext](https://docs.python.org/3/library/gettext.html)
42+
/// - [Python documentation: `gettext` — Multilingual internationalization services](https://docs.python.org/3/library/gettext.html)
4343
#[violation]
4444
pub struct FStringInGetTextFuncCall;
4545

crates/ruff_linter/src/rules/flake8_gettext/rules/format_in_gettext_func_call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::checkers::ast::Checker;
3939
/// ```
4040
///
4141
/// ## References
42-
/// - [Python documentation: gettext](https://docs.python.org/3/library/gettext.html)
42+
/// - [Python documentation: `gettext` — Multilingual internationalization services](https://docs.python.org/3/library/gettext.html)
4343
#[violation]
4444
pub struct FormatInGetTextFuncCall;
4545

crates/ruff_linter/src/rules/flake8_gettext/rules/printf_in_gettext_func_call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use ruff_text_size::Ranged;
3838
/// ```
3939
///
4040
/// ## References
41-
/// - [Python documentation: gettext](https://docs.python.org/3/library/gettext.html)
41+
/// - [Python documentation: `gettext` — Multilingual internationalization services](https://docs.python.org/3/library/gettext.html)
4242
#[violation]
4343
pub struct PrintfInGetTextFuncCall;
4444

crates/ruff_linter/src/rules/flake8_no_pep420/rules/implicit_namespace_package.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::Locator;
2222
///
2323
/// Directories that lack an `__init__.py` file can still be imported, but
2424
/// they're indicative of a special kind of package, known as a "namespace
25-
/// package" (see: [PEP 420](https://www.python.org/dev/peps/pep-0420/)).
25+
/// package" (see: [PEP 420](https://peps.python.org/pep-0420/)).
2626
/// Namespace packages are less widely used, so a package that lacks an
2727
/// `__init__.py` file is typically meant to be a regular package, and
2828
/// the absence of the `__init__.py` file is probably an oversight.

crates/ruff_linter/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::checkers::ast::Checker;
3030
/// ```
3131
///
3232
/// ## References
33-
/// The [typing documentation on stub files](https://typing.readthedocs.io/en/latest/source/stubs.html#version-and-platform-checks)
33+
/// - [Typing documentation: Version and platform checking](https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checks)
3434
#[violation]
3535
pub struct ComplexIfStatementInStub;
3636

crates/ruff_linter/src/rules/flake8_pyi/rules/non_empty_stub_body.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ use crate::checkers::ast::Checker;
2626
/// ```
2727
///
2828
/// ## References
29-
/// - [The recommended style for stub functions and methods](https://typing.readthedocs.io/en/latest/source/stubs.html#id6)
30-
/// in the typing docs.
29+
/// - [Typing documentation - Writing and Maintaining Stub Files](https://typing.readthedocs.io/en/latest/guides/writing_stubs.html)
3130
#[violation]
3231
pub struct NonEmptyStubBody;
3332

crates/ruff_linter/src/rules/flake8_pyi/rules/non_self_return_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ use crate::checkers::ast::Checker;
7171
/// def __iadd__(self, other: Foo) -> Self: ...
7272
/// ```
7373
/// ## References
74-
/// - [`typing.Self` documentation](https://docs.python.org/3/library/typing.html#typing.Self)
74+
/// - [Python documentation: `typing.Self`](https://docs.python.org/3/library/typing.html#typing.Self)
7575
#[violation]
7676
pub struct NonSelfReturnType {
7777
class_name: String,

crates/ruff_linter/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ use crate::checkers::ast::Checker;
2323
/// ```
2424
///
2525
/// ## References
26-
/// The [recommended style for functions and methods](https://typing.readthedocs.io/en/latest/source/stubs.html#functions-and-methods)
27-
/// in the typing docs.
26+
/// - [Typing documentation - Writing and Maintaining Stub Files](https://typing.readthedocs.io/en/latest/guides/writing_stubs.html)
2827
#[violation]
2928
pub struct PassStatementStubBody;
3029

crates/ruff_linter/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::checkers::ast::Checker;
2727
/// ```
2828
///
2929
/// ## References
30-
/// - [Static Typing with Python: Type Stubs](https://typing.readthedocs.io/en/latest/source/stubs.html)
30+
/// - [Typing documentation - Writing and Maintaining Stub Files](https://typing.readthedocs.io/en/latest/guides/writing_stubs.html)
3131
#[violation]
3232
pub struct QuotedAnnotationInStub;
3333

crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use crate::checkers::ast::Checker;
3838
/// ```
3939
///
4040
/// ## References
41-
/// - [The typing specification](https://docs.python.org/3/library/numbers.html#the-numeric-tower)
41+
/// - [Python documentation: The numeric tower](https://docs.python.org/3/library/numbers.html#the-numeric-tower)
4242
/// - [PEP 484: The numeric tower](https://peps.python.org/pep-0484/#the-numeric-tower)
4343
///
4444
/// [typing specification]: https://typing.readthedocs.io/en/latest/spec/special-types.html#special-cases-for-float-and-complex

crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_platform.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use crate::registry::Rule;
4040
/// ```
4141
///
4242
/// ## References
43-
/// - [Typing stubs documentation: Version and Platform Checks](https://typing.readthedocs.io/en/latest/source/stubs.html#version-and-platform-checks)
43+
/// - [Typing documentation: Version and Platform checking](https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checks)
4444
#[violation]
4545
pub struct UnrecognizedPlatformCheck;
4646

@@ -74,7 +74,7 @@ impl Violation for UnrecognizedPlatformCheck {
7474
/// ```
7575
///
7676
/// ## References
77-
/// - [Typing stubs documentation: Version and Platform Checks](https://typing.readthedocs.io/en/latest/source/stubs.html#version-and-platform-checks)
77+
/// - [Typing documentation: Version and Platform checking](https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checks)
7878
#[violation]
7979
pub struct UnrecognizedPlatformName {
8080
platform: String,

crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_version_info.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::registry::Rule;
3131
/// ```
3232
///
3333
/// ## References
34-
/// - [Typing stubs documentation: Version and Platform Checks](https://typing.readthedocs.io/en/latest/source/stubs.html#version-and-platform-checks)
34+
/// - [Typing documentation: Version and Platform checking](https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checks)
3535
#[violation]
3636
pub struct UnrecognizedVersionInfoCheck;
3737

@@ -70,7 +70,7 @@ impl Violation for UnrecognizedVersionInfoCheck {
7070
/// ```
7171
///
7272
/// ## References
73-
/// - [Typing stubs documentation: Version and Platform Checks](https://typing.readthedocs.io/en/latest/source/stubs.html#version-and-platform-checks)
73+
/// - [Typing documentation: Version and Platform checking](https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checks)
7474
#[violation]
7575
pub struct PatchVersionComparison;
7676

@@ -106,7 +106,7 @@ impl Violation for PatchVersionComparison {
106106
/// ```
107107
///
108108
/// ## References
109-
/// - [Typing stubs documentation: Version and Platform Checks](https://typing.readthedocs.io/en/latest/source/stubs.html#version-and-platform-checks)
109+
/// - [Typing documentation: Version and Platform checking](https://typing.readthedocs.io/en/latest/spec/directives.html#version-and-platform-checks)
110110
#[violation]
111111
pub struct WrongTupleLengthVersionComparison {
112112
expected_length: usize,

crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ impl AlwaysFixableViolation for PytestErroneousUseFixturesOnFixture {
590590
/// ```
591591
///
592592
/// ## References
593-
/// - [`pytest-asyncio`](https://pypi.org/project/pytest-asyncio/)
593+
/// - [PyPI: `pytest-asyncio`](https://pypi.org/project/pytest-asyncio/)
594594
#[violation]
595595
pub struct PytestUnnecessaryAsyncioMarkOnFixture;
596596

crates/ruff_linter/src/rules/flake8_pytest_style/rules/patch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use ruff_text_size::Ranged;
3838
///
3939
/// ## References
4040
/// - [Python documentation: `unittest.mock.patch`](https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch)
41-
/// - [`pytest-mock`](https://pypi.org/project/pytest-mock/)
41+
/// - [PyPI: `pytest-mock`](https://pypi.org/project/pytest-mock/)
4242
#[violation]
4343
pub struct PytestPatchWithLambda;
4444

crates/ruff_linter/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::fix;
3131
/// ```
3232
///
3333
/// ## References
34-
/// - [PEP 535](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
34+
/// - [PEP 563: Runtime annotation resolution and `TYPE_CHECKING`](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
3535
#[violation]
3636
pub struct EmptyTypeCheckingBlock;
3737

crates/ruff_linter/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use crate::rules::flake8_type_checking::imports::ImportBinding;
5151
/// - `lint.flake8-type-checking.quote-annotations`
5252
///
5353
/// ## References
54-
/// - [PEP 535](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
54+
/// - [PEP 563: Runtime annotation resolution and `TYPE_CHECKING`](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
5555
#[violation]
5656
pub struct RuntimeImportInTypeCheckingBlock {
5757
qualified_name: String,

crates/ruff_linter/src/rules/flake8_type_checking/rules/runtime_string_union.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ use crate::checkers::ast::Checker;
3737
/// ```
3838
///
3939
/// ## References
40-
/// - [PEP 535](https://peps.python.org/pep-0563/)
41-
/// - [PEP 604](https://peps.python.org/pep-0604/)
40+
/// - [PEP 563 - Postponed Evaluation of Annotations](https://peps.python.org/pep-0563/)
41+
/// - [PEP 604 – Allow writing union types as `X | Y`](https://peps.python.org/pep-0604/)
4242
///
4343
/// [PEP 604]: https://peps.python.org/pep-0604/
4444
#[violation]

crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ use crate::rules::isort::{categorize, ImportSection, ImportType};
7171
/// - `lint.typing-modules`
7272
///
7373
/// ## References
74-
/// - [PEP 536](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
74+
/// - [PEP 563: Runtime annotation resolution and `TYPE_CHECKING`](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
7575
#[violation]
7676
pub struct TypingOnlyFirstPartyImport {
7777
qualified_name: String,
@@ -146,7 +146,7 @@ impl Violation for TypingOnlyFirstPartyImport {
146146
/// - `lint.typing-modules`
147147
///
148148
/// ## References
149-
/// - [PEP 536](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
149+
/// - [PEP 563: Runtime annotation resolution and `TYPE_CHECKING`](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
150150
#[violation]
151151
pub struct TypingOnlyThirdPartyImport {
152152
qualified_name: String,
@@ -221,7 +221,7 @@ impl Violation for TypingOnlyThirdPartyImport {
221221
/// - `lint.typing-modules`
222222
///
223223
/// ## References
224-
/// - [PEP 536](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
224+
/// - [PEP 563: Runtime annotation resolution and `TYPE_CHECKING`](https://peps.python.org/pep-0563/#runtime-annotation-resolution-and-type-checking)
225225
#[violation]
226226
pub struct TypingOnlyStandardLibraryImport {
227227
qualified_name: String,

0 commit comments

Comments
 (0)