Typeerror: ‘classmethod’ object is not callable

For today’s discussion, we will walk you through fixing this “typeerror: ‘classmethod’ object is not callable.”

If you don’t have any idea how to fix this error, keep on reading!

In this article, we will hand you the solutions to this “‘classmethod’ object is not callable” error message.

What is “classmethod” object?

The “classmethod” object is used to define class method in Python. 


It is a built-in object that allows users to define a method as a class method that is bound to a class and not an instance of the class. 

It is created by using the @classmethod decorator above a method definition within a class. 

It is different from a regular method object in that it takes the class as its first argument rather than the instance of the class.

What is “typeerror: ‘classmethod’ object is not callable”?

The “typeerror: ‘classmethod’ object is not callable” is an error message that occurs when you are trying to call a “classmethod object” directly.

In a simple word, this error message occurs when you try to call a “classmethod” as if it were a regular method.

However, Python is treating it as an object of type “classmethod” instead.

A classmethod object is not callable, but the object returned by the classmethod’s get method is callable.

This means that you need to call the get method of the classmethod object to get a callable object.

What are the root causes of this error?

Here are the common root causes of the error:

👎 If you are using the incorrect usage of the “classmethod” decorator.

👎 Confusion between class methods and instance methods.

👎 When you mistakenly try to call a class method using an instance of the class rather than the class itself.

👎 When you accidentally over write the class method with a different object.

How to fix “”typeerror: ‘classmethod’ object is not callable”?”

To fix this error, ensure that you are calling the class method using the class name, and not an instance of the class.

You should also check that the class method is defined correctly, using the “@classmethod” decorator before the method definition.

Here are the different solutions you can use that can help you to get rid of this error:

1. Call the classmethod on the class itself

You can call the my_class_method “classmethod” directly on the MyClass class itself.

This code will work effectively and does not raise an error.

class MyClass:
    x = 100

    @classmethod
    def my_class_method(cls):
        cls.x += 10
        print(cls.x)

MyClass.my_class_method()

Output:

110

2. Call the classmethod on an instance of the class

In here, we create an instance of the MyClass class called my_instance and then call the my_class_method classmethod on this instance.

class MyClass:
    x = 110

    @classmethod
    def my_class_method(cls):
        cls.x += 10
        print(cls.x)

my_instance = MyClass()
my_instance.my_class_method()

Output:

120

3. Use the __get__method

You can also use the __get__method of the my_class_method classmethod object to get a callable object.

Then call the callable object.

class MyClass:
    x = 120

    @classmethod
    def my_class_method(cls):
        cls.x += 10
        print(cls.x)

callable_object = MyClass.my_class_method.__get__(MyClass)
callable_object()

Output:

130

4. Use the __func__attribute

Aside from using the __get__method you can also use the func attribute of the my_class_method classmethod object to get a reference to the underlying function.


Then call this function and pass in a reference to the MyClass class as its first argument.

class MyClass:
    x = 130

    @classmethod
    def my_class_method(cls):
        cls.x += 10
        print(cls.x)

MyClass.my_class_method.__func__(MyClass)

Output:

140

5. Use a staticmethod

Alternatively, you can also use a staticmethod instead of a classmethod.


A staticmethod is similar to a classmethod in that it is bound to the class and not an instance of the class.

class MyClass:
    x = 140

    @staticmethod
    def my_static_method():
        MyClass.x += 10
        print(MyClass.x)

MyClass.my_static_method()

However, it does not receive a reference to the class as its first argument.


Instead, you have to refer to the class explicitly by its name when accessing or modifying its attributes.

Output:

150

Conclusion

The “typeerror: ‘classmethod’ object is not callable” is an error message that occurs when you are trying to call a “classmethod object” directly.

This article already provides several solutions above so that you can fix the error message immediately.

We are hoping that this article provided you with sufficient solutions to get rid of the error.

You could also check out other “typeerror” articles that may help you in the future if you encounter them.

Frequently Asked Questions

What is Python TypeError and what causes it?

TypeError is raised when an operation is applied to an object of the wrong type. Common patterns: calling a non-callable object, adding incompatible types (str + int), passing the wrong number of arguments, or accessing attributes on a NoneType. Each TypeError message names the operation and expected vs actual types, the fix is almost always to convert types explicitly (int(), str()) or fix the wrong variable assignment.

How do I quickly debug a Python TypeError?

Three steps: (1) Read the full error message, it names the exact operation and types involved. (2) Print the type of every variable in that line: print(type(var1), type(var2)). (3) Check what the function expected vs what you passed. Most TypeError fixes are 1-line type casts or fixing a variable that became None unexpectedly.

Should I catch TypeError or let it propagate?

For internal code, let TypeError propagate, it’s almost always a real bug (wrong type passed). For boundary code (parsing user input, third-party API responses), catch TypeError + ValueError together: try: parsed = int(value) except (TypeError, ValueError): parsed = 0. Catching internal TypeErrors hides bugs.

How do I prevent TypeError in production?

Three patterns: (1) Use type hints (def add(a: int, b: int) -> int) and check with mypy / pyright in CI. (2) Validate inputs at boundaries (Pydantic for FastAPI, DRF serializers for Django). (3) Default values that match expected types (return 0 not None for numeric functions). Static typing catches 80% of TypeErrors before runtime.

Where can I find more TypeError fixes?

Browse the TypeError reference hub for 220+ specific TypeError fixes. For broader Python debugging, see the Python Tutorial hub. For related error types, see ValueError and AttributeError guides.

Caren Bautista

Technical Writer at PIES IT Solution

Responsible for crafting clear, well-structured, and beginner-friendly content across the platform. Handles the writing, proofreading, and editorial review of tutorials, guides, and documentation to ensure every article is accurate, readable, and easy to follow.

Expertise: Technical Writing · Content Creation · Documentation · Editorial Writing · JavaScript · TypeScript · Python · Python Errors · HTTP Errors · MS Excel  · View all posts by Caren Bautista →