SubQuery is an abstract base class (per the abc module) with one or more abstract methods that you did not override. By adding ABC to the list of base classes, you defined ValueSum itself to be an abstract base class. That means you aren't forced to override the methods, but it also means you cannot instantiate ValueSum itself.

PyCharm is warning you ahead of time that you need to implement the abstract methods inherited from SubQuery; if you don't, you would get an error from Python when you actually tried to instantiate ValueSum.


As to what inheriting from ABC does, the answer is... not much. It's a convenience for setting the metaclass. The following are equivalent:

class Foo(metaclass=abc.ABCMeta):
    ...

and

class Foo(abc.ABC):
    ...

The metaclass modifies __new__ so that every attempt to create an instance of your class checks that the class has implemented all methods decorated with @abstractmethod in a parent class.

Answer from chepner on Stack Overflow
🌐
Python
docs.python.org › 3 › library › abc.html
abc — Abstract Base Classes
This module provides the infrastructure for defining abstract base classes (ABCs) in Python, as outlined in PEP 3119; see the PEP for why this was added to Python.
🌐
GeeksforGeeks
geeksforgeeks.org › python › abstract-base-class-abc-in-python
Abstract Base Class (abc) in Python - GeeksforGeeks
July 15, 2025 - And finally, using an abstract class, a class can derive identity from another class without any object inheritance. Python has a module called abc (abstract base class) that offers the necessary tools for crafting an abstract base class.
Discussions

Understanding abc.ABC
If I have class A and then I derive subclass B from it wouldn't issubclass(B,A) still be true? Usually, yes, unless you do something weird with metaclasses maybe. I do not understand what abstract classes give you. You can think of them as some kind of "contracts"; any class inheriting from them implicitly makes a promise to support the interface defined by the abstract base class. It's not nearly as binding or robust as something like Rust's trait system, but it can still come in handy sometimes. For example, os.PathLike is an abstract base class that defines a common interface all path-like objects, such as pathlib.Path, must fulfill to be compatible with most standard library functions expecting filepaths as arguments. The subclasses can add more functionality on top of the required methods, but they are forced to at least have the ones set by the abstract base class. In other words, you can always count on those being available no matter what kind of subclass you're getting. More on reddit.com
🌐 r/learnpython
5
1
June 20, 2023
What's the point of ABC & @abstractmethod
So your examples are a bit problematic because you would never use @abstractmethod in that situation. In your example there is no reason not to define the function only in the parent class--the parent knows everything it needs in order to execute the function, and the children don't change the execution at all. Also, Abs is a terrible name for a class. @abstractmethod is for when you: Require all children to have a method Don't have enough information to define that method in the parent Essentially, it "requires" child classes to define this method. This allows you to include the method in your parent interface so you can document it but raises a sensible error if the child doesn't re-define it. This is mostly useful for parent classes that will never have direct instances--only instances of subclasses. Consider designing a shooter game like Doom or Quake. You might represent various objects and enemies as class instances. To keep the game synced, every clock tick all the objects need to "update" themselves. Enemies might move around, lights might blink, and items might recharge. They all need to do something, but what they do is completely unique to each class. In a case like this, you might define the update() method in the parent Object class. This is mostly a convenience feature--you can write the same code perfectly well without it. However, it allows you to refer to all objects collectively (isinstance(o, Object)) through the parent class, and still ensure that update() exists, even though the parent doesn't know what to do with it. You could easily define update() in the parent and have it do nothing, but this prevents errors from being raised if you call this on a child class that hasn't re-defined the method. More on reddit.com
🌐 r/learnpython
11
14
July 27, 2021
Interfaces with Protocols: why not ditch ABC for good?
Whereas with Protocols it's gonna be ( good tutorial ): I think that is not a good example of how to write programs. What he did by having protocols I would have done by using mixins. The way that I see objects is that they have various capabilities that can be mixed in. multiple inheritance in python would have been a much better way to implement that example in my opinion. I would also say that the author of this tutorial needs to learn a thing or 2 about an inversion of control and dependency injection. The author basically sets up a straw man problem and then solves his straw man problem. He had no business creating instances of the object outside of the class itself. If he had simply called a constructor methods within the classes then the other class wouldn't have been attempting to make instances of those other classes. More on reddit.com
🌐 r/Python
34
63
January 22, 2023
Python Collections Library Abstract Base Class (ABC) Question
I think you are talking about this: Changed in version 3.3: Moved Collections Abstract Base Classes to the collections.abc module. For backwards compatibility, they continue to be visible in this module through Python 3.7. Subsequently, they will be removed entirely. More on reddit.com
🌐 r/Python
8
13
October 3, 2018
Top answer
1 of 3
10

SubQuery is an abstract base class (per the abc module) with one or more abstract methods that you did not override. By adding ABC to the list of base classes, you defined ValueSum itself to be an abstract base class. That means you aren't forced to override the methods, but it also means you cannot instantiate ValueSum itself.

PyCharm is warning you ahead of time that you need to implement the abstract methods inherited from SubQuery; if you don't, you would get an error from Python when you actually tried to instantiate ValueSum.


As to what inheriting from ABC does, the answer is... not much. It's a convenience for setting the metaclass. The following are equivalent:

class Foo(metaclass=abc.ABCMeta):
    ...

and

class Foo(abc.ABC):
    ...

The metaclass modifies __new__ so that every attempt to create an instance of your class checks that the class has implemented all methods decorated with @abstractmethod in a parent class.

2 of 3
4

The 'Abstract Base classes" or abc.ABC is a helper class

https://docs.python.org/3/library/abc.html

Here's a snippet of why they exist:

The collections module has some concrete classes that derive from ABCs; these can, of course, be further derived. In addition, the collections.abc submodule has some ABCs that can be used to test whether a class or instance provides a particular interface, for example, if it is hashable or if it is a mapping.

A good example here: https://pymotw.com/2/abc/ | https://pymotw.com/3/abc/

From pymotw:

Forgetting to set the metaclass properly means the concrete implementations do not have their APIs enforced. To make it easier to set up the abstract class properly, a base class is provided that sets the metaclass automatically.

abc_abc_base.py
import abc


class PluginBase(abc.ABC):

    @abc.abstractmethod
    def load(self, input):
        """Retrieve data from the input source
        and return an object.
        """

    @abc.abstractmethod
    def save(self, output, data):
        """Save the data object to the output."""


class SubclassImplementation(PluginBase):

    def load(self, input):
        return input.read()

    def save(self, output, data):
        return output.write(data)


if __name__ == '__main__':
    print('Subclass:', issubclass(SubclassImplementation,
                                  PluginBase))
    print('Instance:', isinstance(SubclassImplementation(),
                                  PluginBase))
🌐
DataCamp
datacamp.com › tutorial › python-abstract-classes
Python Abstract Classes: A Comprehensive Guide with Examples | DataCamp
January 22, 2025 - The ABC class is a built-in Python feature that serves as a fundamental basis for developing abstract classes. You must inherit from ABC to define an abstract class. The class is abstract and cannot be instantiated directly, as indicated by this inheritance.
🌐
Real Python
realpython.com › ref › glossary › abstract-base-class
abstract base class (ABC) | Python Glossary – Real Python
In Python, an abstract base class (ABC) is a class that can’t be instantiated on its own and is designed to be a blueprint for other classes, allowing you to define a common interface for a group of related classes.
🌐
W3Schools
w3schools.com › python › ref_module_abc.asp
Python abc Module
The abc module provides tools for creating Abstract Base Classes (ABCs) and decorators for abstract methods.
🌐
Medium
leapcell.medium.com › elegant-abstractions-mastering-abstract-base-classes-in-advanced-python-bf3739dd815e
Elegant Abstractions: Mastering ABCs in Advanced Python | by Leapcell | Medium
May 2, 2025 - class ABC(metaclass=ABCMeta): """Helper class that provides a standard way to create an ABC using inheritance. """ pass · The code is more concise. It is more in line with the principle of simplicity and intuitiveness in Python.
Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › understanding abc.abc
r/learnpython on Reddit: Understanding abc.ABC
June 20, 2023 -

I am being asked to maintain code that subclasses from abc.ABC. I have read the python documentation, the associated PEP, and even visited pymotw. I do not understand what abstract classes give you.

If I have class A and then I derive subclass B from it wouldn't issubclass(B,A) still be true?

Top answer
1 of 4
4
If I have class A and then I derive subclass B from it wouldn't issubclass(B,A) still be true? Usually, yes, unless you do something weird with metaclasses maybe. I do not understand what abstract classes give you. You can think of them as some kind of "contracts"; any class inheriting from them implicitly makes a promise to support the interface defined by the abstract base class. It's not nearly as binding or robust as something like Rust's trait system, but it can still come in handy sometimes. For example, os.PathLike is an abstract base class that defines a common interface all path-like objects, such as pathlib.Path, must fulfill to be compatible with most standard library functions expecting filepaths as arguments. The subclasses can add more functionality on top of the required methods, but they are forced to at least have the ones set by the abstract base class. In other words, you can always count on those being available no matter what kind of subclass you're getting.
2 of 4
4
Abstract base classes are just classes that aren't meant to be instantiated. It is like a wireframe for shared methods / attributes, without the ABC itself being a legitimate object type. It works the same as regular subclassing in most ways. ABCs usually have the shared methods defined so that if you make a subclass of it and it doesn't implement something the interface was expected to it will throw an error. class PersonNormal: def __init__(self, name: str): self.name = name def say_hi(self): print(f"Hi, I'm {self.name}") class PersonABC(ABC): def __init__(self, name): ... @abstractmethod def say_hi(self): ... class Student(Person): def __init__(self, name: str): super().__init__(name) class Teacher(Person) def __init__(self, name: str): super().__init__(name) def say_hi(self): print(f"Good morning, I'm Mr. {self.name}") # inheriting from PersonNormal A = Person('John') B = Student('Peter') C = Teacher('Tom') A.say_hi() # calls Person.say_hi normally B.say_hi() # calls Person.say_hi since it wasn't overwritten C.say_hi() # calls Teacher.say_hi # inheriting from PersonABC A = Person('John') # TypeError can't instantiate abstract class Person... B = Student('Peter') # TypeError since you didn't overwrite the method C = Teacher('Tom') # works as expected
🌐
Python Course
python-course.eu › oop › the-abc-of-abstract-base-classes.php
20. The 'ABC' of Abstract Base Classes | OOP | python-course.eu
from abc import ABC, abstractmethod class AbstractClassExample(ABC): @abstractmethod def do_something(self): print("Some implementation!") class AnotherSubclass(AbstractClassExample): def do_something(self): super().do_something() print("The enrichment from AnotherSubclass") x = AnotherSubclass() x.do_something() Some implementation! The enrichment from AnotherSubclass ... Enjoying this page? We offer live Python training courses covering the content of this site.
🌐
CodeSignal
codesignal.com › learn › courses › revisiting-oop-concepts-in-python › lessons › understanding-abstract-classes-and-abstract-methods-in-python
Understanding Abstract Classes and Abstract Methods in ...
Think of it as a blueprint for other classes. It often includes one or more abstract methods. A class that inherits from an abstract class must implement all its abstract methods. In Python, the abc (Abstract Base Classes) module provides tools for defining abstract base classes.
🌐
The Python Coding Stack
thepythoncodingstack.com › p › and-now-you-know-your-abc-python-abstract-base-classes
And Now You Know Your ABC - by Stephen Gruppetta
November 1, 2025 - The abstract base class includes the method .finalise_results(), which is marked as an abstract method. Python is expecting a concrete implementation of this method. Any class that inherits from the Event ABC must have a concrete implementation of this method.
🌐
Earthly
earthly.dev › blog › abstract-base-classes-python
Abstract Base Classes in Python - Earthly Blog
July 19, 2023 - Abstract Base Classes (ABCs) offer a solution to these limitations by allowing us to define a set of common methods and attributes that must be implemented by any class that inherits from the ABC.
🌐
El Libro De Python
ellibrodepython.com › abstract-base-class
📕 Interfaces y Abstract Base Class | El Libro De Python
Los abc fueron añadidos a Python en la PEP3119. Simplemente definen una forma de crear interfaces (a través de metaclases) en los que se definen unos métodos (pero no se implementan) y donde se fuerza a las clases que usan ese interfaz a implementar los métodos. Veamos unos ejemplos. El interfaz más sencillo que podemos crear es de la siguiente manera, heredando de abc.ABC.
🌐
Reddit
reddit.com › r/learnpython › what's the point of abc & @abstractmethod
r/learnpython on Reddit: What's the point of ABC & @abstractmethod
July 27, 2021 -

Hello. In this first example, I have a short and straightforward code w/ a class for interface. It doesn't inherit from ABC and doesn't have any abstract methods.

class Abs():
    def __init__(self, name, age):
        self.name = name
        self.age = age
        
    def go_to(self):
        return f"{self.name} is going to {self.place}."
        
class Teacher(Abs):
    place = "work"

class Student(Abs):
    place = "school"
    
t1 = Teacher("James", 56)
s1 = Student("Tim", 15)

print(t1.go_to())
print(s1.go_to())

In this second example, it's the exact opposite.

from abc import ABC, abstractmethod

class Abs(ABC):
    def __init__(self, name, age):
        self.name = name
        self.age = age
        
    @abstractmethod
    def go_to(self):
        ...
        
class Teacher(Abs):
    place = "work"
    
    def go_to(self):
        return f"{self.name} is going to {self.place}."

class Student(Abs):
    place = "school"
    
    def go_to(self):
        return f"{self.name} is going to {self.place}."
    
t1 = Teacher("James", 56)
s1 = Student("Tim", 15)

print(t1.go_to())
print(s1.go_to())

Both examples have the same output. In the tutorials/articles I've read, most times the second example is preferred. In the abstract class, abstract methods get defined and decorated, and then in the inheriting classes they all get redefined with the rest of the logic. What's the point of creating a class w/ abstract methods which later on we redefine? What issue does that solve? Why not just proceed as in the first example - simple, less code, one parent class for the interface, if we need to add other details, we do so in the base class once and handle the extra logic with that additional info there. Doesn't the first code present a better example of loose coupling - just one connection between parent and child classes, where in the second code, we get connections between parent/child in every method that we redefine? I feel like I'm missing something, because to me, the second example is much more spaghetti-like. If anyone can explain why it's a good practice to redefine abstract methods that would be nice. Also, is it a bad practice to write code as in the first example, w/o ABC+@abstractmethod in the parent class?
Thanks.

Top answer
1 of 5
10
So your examples are a bit problematic because you would never use @abstractmethod in that situation. In your example there is no reason not to define the function only in the parent class--the parent knows everything it needs in order to execute the function, and the children don't change the execution at all. Also, Abs is a terrible name for a class. @abstractmethod is for when you: Require all children to have a method Don't have enough information to define that method in the parent Essentially, it "requires" child classes to define this method. This allows you to include the method in your parent interface so you can document it but raises a sensible error if the child doesn't re-define it. This is mostly useful for parent classes that will never have direct instances--only instances of subclasses. Consider designing a shooter game like Doom or Quake. You might represent various objects and enemies as class instances. To keep the game synced, every clock tick all the objects need to "update" themselves. Enemies might move around, lights might blink, and items might recharge. They all need to do something, but what they do is completely unique to each class. In a case like this, you might define the update() method in the parent Object class. This is mostly a convenience feature--you can write the same code perfectly well without it. However, it allows you to refer to all objects collectively (isinstance(o, Object)) through the parent class, and still ensure that update() exists, even though the parent doesn't know what to do with it. You could easily define update() in the parent and have it do nothing, but this prevents errors from being raised if you call this on a child class that hasn't re-defined the method.
2 of 5
3
let's imagine a List interface - we'll have the operations of append and pop class List(ABC): @abstractmethod def append(self, val): pass @abstractmethod def pop(self): pass now we could create class LinkedList(List) and class ArrayList(List) where we'd implement the methods for both of the list types the reason for using ABC and @abstractmethod is because it doesn't make sense to be able to be able to instantiate a List - that doesn't have an implementation. it only describes what behaviour an implementation should have to provide. think of it as providing a contract by which all users of an object know what behaviour to expect abstract classes and methods are more useful in languages such as java where you can't rely on duck typing void doThing(List list) this would take any subclass of List and be checked at compile time to have the expected methods of append and pop
🌐
Python
peps.python.org › pep-3119
PEP 3119 – Introducing Abstract Base Classes | peps.python.org
This PEP proposes a particular strategy for organizing these tests known as Abstract Base Classes, or ABC. ABCs are simply Python classes that are added into an object’s inheritance tree to signal certain features of that object to an external inspector.
🌐
Quora
pythonbeginner.quora.com › What-is-the-difference-between-ABC-and-ABCMeta-in-Python-Please-describe-an-easy-explanation
What is the difference between ABC and ABCMeta in Python? Please describe an easy explanation. - Python Beginner's - Quora
So, in a nutshell, `ABC` is the abstract base class that you inherit from, while `ABCMeta` is the metaclass that allows you to create abstract base classes. They work together to provide a way to define abstract classes and enforce certain behaviors ...
🌐
Python
docs.python.org › 3 › library › collections.abc.html
collections.abc — Abstract Base Classes for Containers
Source code: Lib/_collections_abc.py This module provides abstract base classes that can be used to test whether a class provides a particular interface; for example, whether it is hashable or whet...
🌐
Medium
medium.com › @abhishekjainindore24 › embracing-abstraction-a-dive-into-abstract-classes-in-python-0faf6d83948d
Embracing Abstraction: A Dive into Abstract Classes in Python | by Abhishek Jain | Medium
September 8, 2024 - Abstract classes provide a blueprint ... abstract methods. Python’s abc (Abstract Base Classes) module provides the infrastructure for creating abstract classes....
🌐
Machine Learning Plus
machinelearningplus.com › python › python-abcs-the-complete-guide-to-abstract-base-classes
Python ABCs- The Complete Guide to Abstract Base Classes – Machine Learning Plus
July 10, 2025 - Let’s create an abstract base class called Vehicle with two abstract methods start_engine() and get_fuel_type() that all vehicle types must implement, plus a concrete method get_info() that provides common vehicle information. ... from abc import ABC, abstractmethod # Abstract base class for vehicles class Vehicle(ABC): def __init__(self, brand, model): self.brand = brand self.model = model @abstractmethod def start_engine(self): pass @abstractmethod def get_fuel_type(self): pass # Concrete method - common functionality def get_info(self): return f"{self.brand} {self.model}"