diff --git a/site/ruff/rules/abstract-base-class-without-abstract-method/index.html b/site/ruff/rules/abstract-base-class-without-abstract-method/index.html index 57dea577e..6c9c5c564 100644 --- a/site/ruff/rules/abstract-base-class-without-abstract-method/index.html +++ b/site/ruff/rules/abstract-base-class-without-abstract-method/index.html @@ -820,29 +820,37 @@
Derived from the flake8-bugbear linter.
Checks for abstract classes without abstract methods.
+Checks for abstract classes without abstract methods or abstract class variables. +Annotated but unassigned class variables are regarded as abstract.
Abstract base classes are used to define interfaces. If an abstract base
-class has no abstract methods, you may have forgotten to add an abstract
+class has no abstract methods or abstract class variables, 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, consider removing
the ABC
base class from the class definition.
from abc import ABC
-
+from typing import ClassVar
-class Foo(ABC):
- def method(self):
- bar()
+
+class Foo(ABC):
+ class_var: ClassVar[str] = "assigned"
+
+ def method(self):
+ bar()
Use instead:
from abc import ABC, abstractmethod
-
+from typing import ClassVar
-class Foo(ABC):
- @abstractmethod
- def method(self):
- bar()
+
+class Foo(ABC):
+ class_var: ClassVar[str]
+
+ @abstractmethod
+ def method(self):
+ bar()