

def __setitem__(self, key, val):
    "\n        Allows slice assignment, so long as the slice is an OrderedDict\n        >>> d = OrderedDict()\n        >>> d['a'] = 'b'\n        >>> d['b'] = 'a'\n        >>> d[3] = 12\n        >>> d\n        OrderedDict([('a', 'b'), ('b', 'a'), (3, 12)])\n        >>> d[:] = OrderedDict(((1, 2), (2, 3), (3, 4)))\n        >>> d\n        OrderedDict([(1, 2), (2, 3), (3, 4)])\n        >>> d[::2] = OrderedDict(((7, 8), (9, 10)))\n        >>> d\n        OrderedDict([(7, 8), (2, 3), (9, 10)])\n        >>> d = OrderedDict(((0, 1), (1, 2), (2, 3), (3, 4)))\n        >>> d[1:3] = OrderedDict(((1, 2), (5, 6), (7, 8)))\n        >>> d\n        OrderedDict([(0, 1), (1, 2), (5, 6), (7, 8), (3, 4)])\n        >>> d = OrderedDict(((0, 1), (1, 2), (2, 3), (3, 4)), strict=True)\n        >>> d[1:3] = OrderedDict(((1, 2), (5, 6), (7, 8)))\n        >>> d\n        OrderedDict([(0, 1), (1, 2), (5, 6), (7, 8), (3, 4)])\n\n        >>> a = OrderedDict(((0, 1), (1, 2), (2, 3)), strict=True)\n        >>> a[3] = 4\n        >>> a\n        OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])\n        >>> a[::1] = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])\n        >>> a\n        OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])\n        >>> a[:2] = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4), (4, 5)])\n        Traceback (most recent call last):\n        ValueError: slice assignment must be from unique keys\n        >>> a = OrderedDict(((0, 1), (1, 2), (2, 3)))\n        >>> a[3] = 4\n        >>> a\n        OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])\n        >>> a[::1] = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])\n        >>> a\n        OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])\n        >>> a[:2] = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])\n        >>> a\n        OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])\n        >>> a[::-1] = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])\n        >>> a\n        OrderedDict([(3, 4), (2, 3), (1, 2), (0, 1)])\n\n        >>> d = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])\n        >>> d[:1] = 3\n        Traceback (most recent call last):\n        TypeError: slice assignment requires an OrderedDict\n\n        >>> d = OrderedDict([(0, 1), (1, 2), (2, 3), (3, 4)])\n        >>> d[:1] = OrderedDict([(9, 8)])\n        >>> d\n        OrderedDict([(9, 8), (1, 2), (2, 3), (3, 4)])\n        "
    if isinstance(key, slice):
        if (not isinstance(val, OrderedDict)):
            raise TypeError('slice assignment requires an OrderedDict')
        keys = self._sequence[key]
        indexes = range(len(self._sequence))[key]
        if (key.step is None):
            pos = (key.start or 0)
            del self[key]
            newkeys = val.keys()
            for k in newkeys:
                if (k in self):
                    if self.strict:
                        raise ValueError('slice assignment must be from unique keys')
                    else:
                        del self[k]
            self._sequence = ((pos._sequence[:pos] + newkeys) + self._sequence[pos:])
            dict.update(self, val)
        else:
            if (len(keys) != len(val)):
                raise ValueError(('attempt to assign sequence of size %s to extended slice of size %s' % (len(val), len(keys))))
            del self[key]
            item_list = zip(indexes, val.items())
            item_list.sort()
            for (pos, (newkey, newval)) in item_list:
                if (self.strict and (newkey in self)):
                    raise ValueError('slice assignment must be from unique keys')
                self.insert(pos, newkey, newval)
    else:
        if (key not in self):
            self._sequence.append(key)
        dict.__setitem__(self, key, val)

dataset/ETHPy150Open editorconfig/editorconfig-vim/plugin/editorconfig-core-py/editorconfig/odict.py OrderedDict.__setitem__/VarMisuse@154/1457 `self`->`pos`