{"record":{"id":"913c3058d721543b","repo":"arduino/Arduino","slug":"expected-at-most-1-arguments-got-d","errorCode":null,"errorMessage":"expected at most 1 arguments, got %d","messagePattern":"expected at most 1 arguments, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/ordered_dict.py","lineNumber":36,"sourceCode":"    'Dictionary that remembers insertion order'\n    # An inherited dict maps keys to values.\n    # The inherited dict provides __getitem__, __len__, __contains__, and get.\n    # The remaining methods are order-aware.\n    # Big-O running times for all methods are the same as for regular dictionaries.\n\n    # The internal self.__map dictionary maps keys to links in a doubly linked list.\n    # The circular doubly linked list starts and ends with a sentinel element.\n    # The sentinel element never gets deleted (this simplifies the algorithm).\n    # Each link is stored as a list of length three:  [PREV, NEXT, KEY].\n\n    def __init__(self, *args, **kwds):\n        '''Initialize an ordered dictionary.  Signature is the same as for\n        regular dictionaries, but keyword arguments are not recommended\n        because their insertion order is arbitrary.\n\n        '''\n        if len(args) > 1:\n            raise TypeError('expected at most 1 arguments, got %d' % len(args))\n        try:\n            self.__root\n        except AttributeError:\n            self.__root = root = []                     # sentinel node\n            root[:] = [root, root, None]\n            self.__map = {}\n        self.__update(*args, **kwds)\n\n    def __setitem__(self, key, value, dict_setitem=dict.__setitem__):\n        'od.__setitem__(i, y) <==> od[i]=y'\n        # Setting a new item creates a new link which goes at the end of the linked\n        # list, and the inherited dictionary is updated with the new key/value pair.\n        if key not in self:\n            root = self.__root\n            last = root[0]\n            last[1] = root[0] = self.__map[key] = [last, root, key]\n        dict_setitem(self, key, value)\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/packages/ordered_dict.py#L18-L54","documentation":"This pure-Python OrderedDict backport mirrors CPython's dict/OrderedDict constructor signature: it accepts at most one positional argument (an iterable of key/value pairs). If __init__ receives more than one positional argument it raises TypeError('expected at most 1 arguments, got N'), matching the error a regular dict would raise.","triggerScenarios":"Calling OrderedDict(mapping1, mapping2) or OrderedDict(iterable, anyOtherArg) — i.e. two or more positional arguments — on this vendored backport (triggered internally when urllib3 or hosts code builds headers from multiple dicts positionally).","commonSituations":"Porting Python 3 dict-merge style code `OrderedDict(d1, **d2)` expecting update semantics; code written for Python 2.7 backports merging two header dicts; passing a default dict plus an override dict positionally.","solutions":["Merge the inputs into one iterable first: pass a single list of pairs, e.g. OrderedDict(list(d1.items()) + list(d2.items())).","Use keyword arguments plus a single positional: OrderedDict(d1, **d2) is still one positional argument and is accepted.","Create empty OrderedDict then update: od = OrderedDict(); od.update(d1); od.update(d2).","On Python 3, prefer collections.OrderedDict or dict | merge syntax instead of the vendored backport."],"exampleFix":"// before\nod = OrderedDict(headers, extra_headers)  # TypeError: expected at most 1 arguments, got 2\n// after\nod = OrderedDict(list(headers.items()) + list(extra_headers.items()))","handlingStrategy":"validation","validationCode":"def build_ordered_dict(*mappings):\n    merged = []\n    for m in mappings:\n        merged.extend(m.items() if hasattr(m, 'items') else m)\n    if len(mappings) > 1:\n        return __import__('collections').OrderedDict(merged)  # merge manually, never pass >1 positional\n    return __import__('collections').OrderedDict(*mappings)","typeGuard":"def is_single_positional_mapping(args):\n    return len(args) <= 1 and (len(args) == 0 or hasattr(args[0], 'keys') or hasattr(args[0], '__iter__'))","tryCatchPattern":"try:\n    od = OrderedDict(d1, d2)\nexcept TypeError as e:\n    if 'expected at most 1 arguments' in str(e):\n        od = OrderedDict(list(d1.items()) + list(d2.items()))\n    else:\n        raise","preventionTips":["Never pass more than one positional argument to OrderedDict; merge iterables first or use **kwargs.","Add a lint rule/tests that construct OrderedDict only with a single pairs-list.","On Python 3.5+, use collections.OrderedDict (which supports update-style patterns) instead of vendored backports.","When merging headers, be explicit about precedence: OrderedDict(list(a.items()) + list(b.items())) keeps b's keys later."],"tags":["python","typeerror","arguments","ordered-dict"],"backgroundTag":"invalid-argument","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}