mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:24 +00:00
Make B024 and B027 documentation more nuanced (#11341)
Closes https://github.com/astral-sh/ruff/issues/11334.
This commit is contained in:
parent
caf01472d5
commit
702d2fa1eb
1 changed files with 8 additions and 10 deletions
|
@ -14,12 +14,12 @@ use crate::registry::Rule;
|
||||||
/// Checks for abstract classes without abstract methods.
|
/// Checks for abstract classes without abstract methods.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// Abstract base classes are used to define interfaces. If they have no abstract
|
/// Abstract base classes are used to define interfaces. If an abstract base
|
||||||
/// methods, they are not useful.
|
/// class has no abstract methods, you may have forgotten to add an abstract
|
||||||
|
/// method to the class or omitted an `@abstractmethod` decorator.
|
||||||
///
|
///
|
||||||
/// If the class is not meant to be used as an interface, it should not be an
|
/// If the class is _not_ meant to be used as an interface, consider removing
|
||||||
/// abstract base class. Remove the `ABC` base class from the class definition,
|
/// the `ABC` base class from the class definition.
|
||||||
/// or add an abstract method to the class.
|
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```python
|
/// ```python
|
||||||
|
@ -62,11 +62,9 @@ impl Violation for AbstractBaseClassWithoutAbstractMethod {
|
||||||
/// decorator.
|
/// decorator.
|
||||||
///
|
///
|
||||||
/// ## Why is this bad?
|
/// ## Why is this bad?
|
||||||
/// Empty methods in abstract base classes without an abstract decorator are
|
/// Empty methods in abstract base classes without an abstract decorator may be
|
||||||
/// indicative of unfinished code or a mistake.
|
/// be indicative of a mistake. If the method is meant to be abstract, add an
|
||||||
///
|
/// `@abstractmethod` decorator to the method.
|
||||||
/// Instead, add an abstract method decorated to indicate that it is abstract,
|
|
||||||
/// or implement the method.
|
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```python
|
/// ```python
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue