Check for abstract base class definitions with no abstractmethods
See original GitHub issuefrom abc import ABC, ABCMeta, abstractmethod
class Base(ABC): # I'd like a lint error here if there are no @abstract* decorated methods
# @abstractmethod
def method(self):
...
class MyABC(metaclass=ABCMeta): # and here too for the same reason
pass
Suggested message: {classname} is an abstract base class, but it has no abstract methods. Remember to use @abstractmethod, @abstractclassmethod, and/or @abstractproperty decorators.
We might also want to emit a warning for a probably-missing-decorator on any method of an ABC where the whole method body is ..., even if there are some abstract-decorated methods on the class.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Can we define an abstract class without abstract method in ...
And yes, you can declare abstract class without defining an abstract method in it. Once you declare a class abstract it indicates that...
Read more >Defining an abstract class without any abstract methods
Yes we can have an abstract class without Abstract Methods as both are independent concepts. Declaring a class abstract means that ...
Read more >Abstract Methods and Classes (The Java™ Tutorials ...
An abstract class is a class that is declared abstract —it may or may not include abstract methods. Abstract classes cannot be instantiated,...
Read more >Writing Abstract Classes and Methods
Sometimes, a class that you define represents an abstract concept and as such, should not be instantiated. Take, for example, food in the...
Read more >Abstract Class in Java - GeeksforGeeks
If the Child class is unable to provide implementation to all abstract methods of the Parent class then we should declare that Child...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m not a fan of that tbh as we don’t have good enough change log enforcement etc. with this project so the 1 commit + release via GitHub is there enough for me imo.
I’m starting on a PR now!
How about extending this to the body being anything but
pass,...or string constants - to also catchSimilar to pyright’s check for
@overloadwith an implementation https://github.com/microsoft/pyright/blob/6fa755c025cb5b18838d8bfdd85761184afa45f1/packages/pyright-internal/src/analyzer/parseTreeUtils.ts#L1999