python call-signature ai_generated true

TypeError: __init__() missing 1 required positional argument: 'name'

ID: python/typeerror-missing-required-arg

Also available as: JSON · Markdown
98%Fix Rate
99%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
311 active

Root Cause

Function or method called without providing all required arguments.

generic

Workarounds

  1. 98% success Pass all required arguments: MyClass(name='value') or check the function signature
    Use help(func) or inspect.signature(func) to see required parameters

    Sources: https://docs.python.org/3/library/inspect.html#inspect.signature

  2. 93% success If subclassing, ensure super().__init__() is called with all required args
    super().__init__(name=name) — pass through parent's required parameters

Dead Ends

Common approaches that don't work:

  1. Making all arguments optional with defaults 65% fail

    Hides API contract; None defaults cause AttributeError later

  2. Using *args to absorb extra/missing arguments 80% fail

    Breaks function signatures; IDE help becomes useless

Error Chain

Frequently confused with: