fuckingpython.lol

Python errors › TypeError

TypeError: missing 1 required positional argument

Updated

The Python error "missing 1 required positional argument" names the parameter that got no value. When it says 'self', the class was never instantiated. The fix.

What you see

main.py
def area(width, height):
    return width * height

print(area(3))
Python 3.15 prints
Traceback (most recent call last):
  File "/home/me/project/main.py", line 4, in <module>
    print(area(3))
          ~~~~^^^
TypeError: area() missing 1 required positional argument: 'height'

What it means

The function was called with fewer arguments than it has parameters without defaults. The message names each parameter that got nothing, 'height' here.

Why it happens

  • An argument left out of the call, as in the example.
  • A class used without being instantiated. Greeter.hello("Ada") calls the method on the class itself, so "Ada" goes to self and name is missing. With no argument at all the message says 'self'.
  • Brackets missing after the class name: g = Greeter instead of g = Greeter().
  • A callback that is called with fewer arguments than it was written for, by a framework or by map().

How to fix it

Pass the argument, or give the parameter a default if it is optional:

def area(width, height=1):
    return width * height

When the missing name is self, create an object first and call the method on it:

greeter = Greeter()
greeter.hello("Ada")

Example: a method called on the class

main.py
class Greeter:
    def hello(self, name):
        return f"Hello, {name}"

print(Greeter.hello("Ada"))
Python 3.15 prints
Traceback (most recent call last):
  File "/home/me/project/main.py", line 5, in <module>
    print(Greeter.hello("Ada"))
          ~~~~~~~~~~~~~^^^^^^^
TypeError: Greeter.hello() missing 1 required positional argument: 'name'
PythonPrints
3.9TypeError: hello() missing 1 required positional argument: 'name'
3.10–3.15TypeError: Greeter.hello() missing 1 required positional argument: 'name'

Run on CPython 3.9.6, 3.10.22, 3.11.17, 3.12.15, 3.13.17, 3.14.9 and 3.15.1, on October 25, 2026.

How each Python version words it

PythonPrints
3.9–3.15TypeError: area() missing 1 required positional argument: 'height'

Run on CPython 3.9.6, 3.10.22, 3.11.17, 3.12.15, 3.13.17, 3.14.9 and 3.15.1, on October 25, 2026.

The wording is the same apart from the name: from 3.10 a method is named with its class, "Greeter.hello()".

Questions

Can I make an argument optional?

Give it a default in the definition, def area(width, height=1). Parameters with defaults must come after those without.

Why "missing 1 required positional argument: 'self'"?

The method was called on the class rather than on an instance, so nothing filled self. Instantiate the class with brackets and call the method on the result.

Sources

Read on October 25, 2026.