arduino/Arduino · error · TypeError

update() takes at least 1 argument (0 given)

Error message

update() takes at least 1 argument (0 given)

What it means

The vendored OrderedDict.update() requires at least one positional argument (the self instance in its unbound-style signature); calling it with zero positional arguments raises this TypeError. In practice this happens when update() is invoked as an unbound method without an OrderedDict instance, or with no mapping/iterable source at all.

Source

Thrown at arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/ordered_dict.py:156

    def iteritems(self):
        'od.iteritems -> an iterator over the (key, value) items in od'
        for k in self:
            yield (k, self[k])

    def update(*args, **kwds):
        '''od.update(E, **F) -> None.  Update od from dict/iterable E and F.

        If E is a dict instance, does:           for k in E: od[k] = E[k]
        If E has a .keys() method, does:         for k in E.keys(): od[k] = E[k]
        Or if E is an iterable of items, does:   for k, v in E: od[k] = v
        In either case, this is followed by:     for k, v in F.items(): od[k] = v

        '''
        if len(args) > 2:
            raise TypeError('update() takes at most 2 positional '
                            'arguments (%d given)' % (len(args),))
        elif not args:
            raise TypeError('update() takes at least 1 argument (0 given)')
        self = args[0]
        # Make progressively weaker assumptions about "other"
        other = ()
        if len(args) == 2:
            other = args[1]
        if isinstance(other, dict):
            for key in other:
                self[key] = other[key]
        elif hasattr(other, 'keys'):
            for key in other.keys():
                self[key] = other[key]
        else:
            for key, value in other:
                self[key] = value
        for key, value in kwds.items():
            self[key] = value

    __update = update  # let subclasses override update without breaking __init__

View on GitHub (pinned to a0df6e0e83)

Solutions

  1. Call it as a bound method on an instance with one source: od.update(mapping).
  2. If updating from kwargs on this backport, pass a dict: od.update(kwargs_dict).
  3. Ensure the class is instantiated before updating instead of calling the function object directly.

Example fix

// before
OrderedDict.update({'a': 1})  # unbound, missing instance
// after
od = OrderedDict()
od.update({'a': 1})
Defensive patterns

Strategy: validation

Validate before calling

if not isinstance(od, dict):
    raise TypeError('update() must be called on an OrderedDict instance')
assert source is not None

Type guard

def is_ordered_dict(o):
    return isinstance(o, dict) and hasattr(o, 'popitem') and hasattr(o, 'move_to_end') or isinstance(o, dict)

Try / catch

try:
    od.update(source)
except TypeError as e:
    if 'at least 1 argument' in str(e):
        raise ValueError('update() called without a source mapping') from e
    raise

Prevention

When it happens

Trigger: Calling OrderedDict.update() with no arguments; calling it unbound as OrderedDict.update(other) where `other` lands in the self slot; keyword-only usage like od.update(**kwargs) with no positional arg.

Common situations: Porting dict.update(**kw) style calls that worked on built-in dict but not on this backport; reflecting/patching update() and dropping the instance argument.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of arduino/Arduino@a0df6e0e83 (2026-09-06). Data as JSON: /api/errors/a940257a10fe2a0f. Report an issue: GitHub.