Typeerror: nonetype object is not callable

When we call the object having the value None, we might encounter TypeError: ‘nonetype’ object is not callable.

In this guide, we will deal with this error, why it occurs, and what it means.

Apart from that, we have example codes, and scenarios to help you understand the error and solve it quickly in your program.

When working with Python, Nonetype data type is used to store the None value.

Additionally, the keyword None is used to store the value none/null in a variable.

Now let’s understand why we get Typeerror: nonetype object is not callable.

What is Typeerror: nonetype object is not callable?

The Typeerror: nonetype object is not a callable error occurs if we call the None value as if it is a function.

To fix it, find where the values come from, hence correct the assignment, or get rid of the parenthesis.

Common Causes of ‘nonetype’ object is not callable

The common causes of this error include the following:

  1. Calling the None value inside the parenthesis as if it is a function.
  2. Having the same name for a variable and a function.
  3. Trying to call the function twice that returns twice.
  4. The calls method and class property have the same name.
  5. By mistake overriding the built-in function and setting it to None.

Example Scenario of nonetype object is not callable

Certainly, here is an example scenario of how this error occurs:

def get_name():
    return None

name = get_name()
print(name())

In our example code, the get_name() function returns None, which means that the name variable will also have a value of None.

When we try to call name() in the print statement, we are essentially trying to call None as if it were a function.

Wherein it is not possible and will result in the “Typeerror: nonetype object is not callable” error message.

Now that you know how possibly it occurs, let’s fix it in the next section.

How to fix typeerror: ‘nonetype’ object is not callable

Here are the following solutions you can use depending on the cause of the error.

1. Rename the method of the Class

One of the causes of the error is having the same name of the class method and class property.

Take a look at this code snippet where it triggers the error:

class MyExample():
    def __init__(self):
        self.name = None

    def name(self):
        return self.name

ex1 = MyExample()

# TypeError: 'NoneType' object is not callable
print(ex1.name())

As you can see in the code Myexample have the same name on the attribute.

In which the attributes hide the method, so when the instance of the class is called in the method…

We trigger the error.

To fix the error make sure to change the name of the method of a class.

class MyExample():
    def __init__(self):
        self.name = None

    def get_name(self):
        return self.name

ex1 = MyExample()

print(ex1.get_name())  # returns None

Expected output:

None

2. Function and a variable with the same name

Another way to fix the error is to avoid having the same name on a function and variable.

Take a look at the example code below:

def example():
    return 'I love itsourcecode'

example = None

# TypeError: 'NoneType' object is not callable
example()

Output:

Traceback (most recent call last):
  File "C:\Users\Windows\PycharmProjects\pythonProject\main.py", line 7, in <module>
    example()
TypeError: 'NoneType' object is not callable

Having the same name in function and variable shadow the function set to None.

Wherein every time we call the function, we end up calling the variable.

Here is an example snippet code that fixed the error:

def Myexample():
    return 'I love itsourcecode'

My_var = None

print(Myexample())  # I love itsourcecode

Expected Output:

I love itsourcecode

3. Remove the extra Parenthesis

Another cause of the error is having an extra parenthesis.

Examine the example error code below.

def example(x):
    x()

def another_func():
    print('I love itsourcecode')


# TypeError: 'NoneType' object is not callable
example(another_func())

The example function takes another function as an argument and calls it.

However, notice that we called the other function when passing it to example.

The function returns None, so the example function got called with a None value.

To fix the error we need to remove the extra parenthesis to call the example function.

def example(x):
    x()


def another_func():
    print('I love itsourcecode')


example(another_func)  # I love itsourcecode

Expected output:

I love itsourcecode

Now the example function gets called with a function that invokes it and prints the message.

4. Check the return value of the method before calling it

Check the return value of the method before calling it. We can modify the method to return a lambda function that returns None.

Example error code:

class MyClass:
    def my_method(self):
        return None

my_obj = MyClass()
result = my_obj.my_method()()
print(result)

Output

TypeError: 'NoneType' object is not callable

To fix this we should modify the method to return lambda function that returns None.

Here is the snippet code:

class MyClass:
    def my_method(self):
        return lambda: None

my_obj = MyClass()
result = my_obj.my_method()()
print(result)

Output:

None

Conclusion

In conclusion, in fixing TypeError: ‘NoneType’ object is not callableerror we take note of the following:

  • Avoid having the same name on a function and a variable.
  • Avoid having the same name on the class method and property.
  • Do not call a None value with parentheses ().
  • Do not override a built-in function and set it to None.
  • Do not call a function that returns None twice.

If you are finding solutions to some errors you might encounter we also have Typeerror object of type float32 is not json serializable.

Thank you for reading!

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.

Glay Eliver

Programmer & Technical Writer at PIES IT Solution

Glay Eliver is a programmer and writer at PIES IT Solution, author of over 600 tutorials at itsourcecode.com. Specializes in JavaScript tutorials, Microsoft Office how-tos (Excel, Word, PowerPoint), and Python error debugging covering ImportError, TypeError, AttributeError, ModuleNotFoundError, and JavaScript ReferenceError. Authored several of the site’s highest-traffic Excel and MS Office reference articles.

Expertise: JavaScript · MS Excel · MS Word · MS PowerPoint · Python · Python ImportError · Python TypeError · Python AttributeError · ModuleNotFoundError · JavaScript ReferenceError · Pygame  · View all posts by Glay Eliver →