mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
Normalize some docs sections (#18831)
This commit is contained in:
parent
e36611c4d8
commit
ef785d2e74
24 changed files with 10 additions and 26 deletions
|
@ -58,7 +58,6 @@ use crate::{AlwaysFixableViolation, Fix};
|
|||
/// async def create_item(item: Item) -> Item:
|
||||
/// return item
|
||||
/// ```
|
||||
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct FastApiRedundantResponseModel;
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ use crate::rules::flake8_builtins::helpers::shadows_builtin;
|
|||
/// ## Options
|
||||
/// - `lint.flake8-builtins.ignorelist`
|
||||
/// - `target-version`
|
||||
///
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct BuiltinImportShadowing {
|
||||
name: String,
|
||||
|
|
|
@ -31,7 +31,7 @@ use crate::{AlwaysFixableViolation, Fix};
|
|||
/// ...
|
||||
/// ```
|
||||
///
|
||||
/// ## Fix Safety
|
||||
/// ## Fix safety
|
||||
/// This fix is always marked as unsafe since we cannot know
|
||||
/// for certain which assignment was intended.
|
||||
#[derive(ViolationMetadata)]
|
||||
|
|
|
@ -53,7 +53,7 @@ use crate::{Applicability, Edit, Fix, FixAvailability, Violation};
|
|||
/// def bar(cls, arg: int) -> Self: ...
|
||||
/// ```
|
||||
///
|
||||
/// ## Fix behaviour and safety
|
||||
/// ## Fix behaviour
|
||||
/// The fix replaces all references to the custom type variable in the method's header and body
|
||||
/// with references to `Self`. The fix also adds an import of `Self` if neither `Self` nor `typing`
|
||||
/// is already imported in the module. If your [`target-version`] setting is set to Python 3.11 or
|
||||
|
@ -67,6 +67,7 @@ use crate::{Applicability, Edit, Fix, FixAvailability, Violation};
|
|||
/// [`unused-private-type-var`][PYI018] for a rule that will clean up unused private type
|
||||
/// variables.
|
||||
///
|
||||
/// ## Fix safety
|
||||
/// The fix is only marked as unsafe if there is the possibility that it might delete a comment
|
||||
/// from your code.
|
||||
///
|
||||
|
|
|
@ -187,7 +187,6 @@ impl Violation for PytestAssertAlwaysFalse {
|
|||
///
|
||||
/// ## References
|
||||
/// - [`pytest` documentation: Assertion introspection details](https://docs.pytest.org/en/7.1.x/how-to/assert.html#assertion-introspection-details)
|
||||
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct PytestUnittestAssertion {
|
||||
assertion: String,
|
||||
|
|
|
@ -52,10 +52,9 @@ use super::super::visitor::{ReturnVisitor, Stack};
|
|||
/// return
|
||||
/// ```
|
||||
///
|
||||
/// ## Fix Safety
|
||||
/// ## Fix safety
|
||||
/// This rule's fix is marked as unsafe for cases in which comments would be
|
||||
/// dropped from the `return` statement.
|
||||
///
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UnnecessaryReturnNone;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ use crate::{FixAvailability, Violation};
|
|||
/// pass
|
||||
/// ```
|
||||
///
|
||||
/// # Fix safety
|
||||
/// ## Fix safety
|
||||
///
|
||||
/// This fix is marked as always unsafe unless [preview] mode is enabled, in which case it is always
|
||||
/// marked as safe. Note that the fix is unavailable if it would remove comments (in either case).
|
||||
|
|
|
@ -34,7 +34,7 @@ use crate::{Edit, Fix, FixAvailability, Violation};
|
|||
/// return any(predicate(item) for item in iterable)
|
||||
/// ```
|
||||
///
|
||||
/// # Fix safety
|
||||
/// ## Fix safety
|
||||
///
|
||||
/// This fix is always marked as unsafe because it might remove comments.
|
||||
///
|
||||
|
|
|
@ -28,7 +28,7 @@ use crate::rules::flynt::helpers;
|
|||
/// f"{foo} {bar}"
|
||||
/// ```
|
||||
///
|
||||
/// # Fix safety
|
||||
/// ## Fix safety
|
||||
/// The fix is always marked unsafe because the evaluation of the f-string
|
||||
/// expressions will default to calling the `__format__` method of each
|
||||
/// object, whereas `str.join` expects each object to be an instance of
|
||||
|
|
|
@ -32,7 +32,6 @@ use crate::rules::pycodestyle::helpers::is_ambiguous_name;
|
|||
/// o = 123
|
||||
/// i = 42
|
||||
/// ```
|
||||
///
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct AmbiguousVariableName(pub String);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ use crate::{AlwaysFixableViolation, Applicability, Edit, Fix};
|
|||
/// spam(1)\n#
|
||||
/// ```
|
||||
///
|
||||
/// ## Fix Safety
|
||||
/// ## Fix safety
|
||||
///
|
||||
/// This fix is marked unsafe if the whitespace is inside a multiline string,
|
||||
/// as removing it changes the string's content.
|
||||
|
@ -62,7 +62,7 @@ impl AlwaysFixableViolation for TrailingWhitespace {
|
|||
/// class Foo(object):\n\n bang = 12
|
||||
/// ```
|
||||
///
|
||||
/// ## Fix Safety
|
||||
/// ## Fix safety
|
||||
///
|
||||
/// This fix is marked unsafe if the whitespace is inside a multiline string,
|
||||
/// as removing it changes the string's content.
|
||||
|
|
|
@ -29,7 +29,6 @@ use crate::{AlwaysFixableViolation, Edit, Fix};
|
|||
/// ```
|
||||
///
|
||||
/// [PEP 8]: https://peps.python.org/pep-0008/#maximum-line-length
|
||||
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct WhitespaceAfterDecorator;
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ use crate::checkers::ast::Checker;
|
|||
/// for instrument, section in ORCHESTRA.items():
|
||||
/// print(f"{instrument}: {section}")
|
||||
/// ```
|
||||
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct DictIndexMissingItems;
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ use crate::checkers::ast::Checker;
|
|||
/// url = "www.example.com"
|
||||
/// prefix = url.split(".", maxsplit=1)[0]
|
||||
/// ```
|
||||
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct MissingMaxsplitArg;
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ use crate::linter::float::as_nan_float_string_literal;
|
|||
/// if math.isnan(x):
|
||||
/// pass
|
||||
/// ```
|
||||
///
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct NanComparison {
|
||||
nan: Nan,
|
||||
|
|
|
@ -27,7 +27,6 @@ use crate::checkers::ast::Checker;
|
|||
/// _, b, a = (1, 2, 3)
|
||||
/// print(a) # 3
|
||||
/// ```
|
||||
///
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct RedeclaredAssignedName {
|
||||
name: String,
|
||||
|
|
|
@ -29,7 +29,6 @@ use crate::Violation;
|
|||
///
|
||||
/// ## References
|
||||
/// - [Pylint documentation](https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/redefined-argument-from-local.html)
|
||||
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct RedefinedArgumentFromLocal {
|
||||
pub(crate) name: String,
|
||||
|
|
|
@ -62,7 +62,6 @@ use ruff_python_ast::PythonVersion;
|
|||
/// def is_greater_than_two(x: int) -> bool:
|
||||
/// return x > 2
|
||||
/// ```
|
||||
///
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UnnecessaryDunderCall {
|
||||
method: String,
|
||||
|
|
|
@ -76,7 +76,6 @@ use crate::{Edit, Fix, FixAvailability, Violation};
|
|||
/// - [enum.StrEnum](https://docs.python.org/3/library/enum.html#enum.StrEnum)
|
||||
///
|
||||
/// [breaking change]: https://blog.pecar.me/python-enum
|
||||
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct ReplaceStrEnum {
|
||||
name: String,
|
||||
|
|
|
@ -24,7 +24,6 @@ use crate::{checkers::ast::Checker, importer::ImportRequest};
|
|||
///
|
||||
/// ## References
|
||||
/// - [Python documentation: `Path.cwd`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.cwd)
|
||||
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct ImplicitCwd;
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ use crate::{AlwaysFixableViolation, Edit, Fix};
|
|||
/// if re.match("^hello", "hello world", re.IGNORECASE):
|
||||
/// ...
|
||||
/// ```
|
||||
///
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct RegexFlagAlias {
|
||||
flag: RegexFlag,
|
||||
|
|
|
@ -28,7 +28,7 @@ use crate::{AlwaysFixableViolation, Edit, Fix};
|
|||
/// num = Decimal("1.2345")
|
||||
/// ```
|
||||
///
|
||||
/// ## Fix Safety
|
||||
/// ## Fix safety
|
||||
/// This rule's fix is marked as unsafe because it changes the underlying value
|
||||
/// of the `Decimal` instance that is constructed. This can lead to unexpected
|
||||
/// behavior if your program relies on the previous value (whether deliberately or not).
|
||||
|
|
|
@ -54,7 +54,6 @@ use super::suppression_comment_visitor::{
|
|||
///
|
||||
/// This fix is always marked as unsafe because it deletes the invalid suppression comment,
|
||||
/// rather than trying to move it to a valid position, which the user more likely intended.
|
||||
///
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct InvalidFormatterSuppressionComment {
|
||||
reason: IgnoredReason,
|
||||
|
|
|
@ -33,7 +33,6 @@ use crate::{AlwaysFixableViolation, Applicability, Edit, Fix};
|
|||
///
|
||||
/// The fix is marked unsafe if it is not possible to guarantee that the first argument of
|
||||
/// `round()` is of type `int`, or if the fix deletes comments.
|
||||
///
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct UnnecessaryRound;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue