diff options
author | Taneli Hukkinen <hukkinj1@users.noreply.github.com> | 2020-05-13 20:41:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-13 11:41:25 -0700 |
commit | e0a07ab5bf65d416967f624172644d7846616569 (patch) | |
tree | d9221b6c256e70750516ca8c68bbf5ba7b6498a8 /immutables | |
parent | 51b1871ad20da16b257ec782f73c607d5fcf5f85 (diff) | |
download | immutables-e0a07ab5bf65d416967f624172644d7846616569.tar.gz immutables-e0a07ab5bf65d416967f624172644d7846616569.zip |
Fix errors when a kwarg is named "col" (#35)
Diffstat (limited to 'immutables')
-rw-r--r-- | immutables/map.py | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/immutables/map.py b/immutables/map.py index a8cffd4..ac7ebd7 100644 --- a/immutables/map.py +++ b/immutables/map.py @@ -433,7 +433,17 @@ class MapItems: class Map: - def __init__(self, col=None, **kw): + def __init__(self, *args, **kw): + if not args: + col = None + elif len(args) == 1: + col = args[0] + else: + raise TypeError( + "immutables.Map expected at most 1 arguments, " + "got {}".format(len(args)) + ) + self.__count = 0 self.__root = BitmapNode(0, 0, [], 0) self.__hash = -1 @@ -483,8 +493,18 @@ class Map: return True - def update(self, col=None, **kw): + def update(self, *args, **kw): + if not args: + col = None + elif len(args) == 1: + col = args[0] + else: + raise TypeError( + "update expected at most 1 arguments, got {}".format(len(args)) + ) + it = None + if col is not None: if hasattr(col, 'items'): it = iter(col.items()) @@ -721,7 +741,16 @@ class MapMutation: else: return True - def update(self, col=None, **kw): + def update(self, *args, **kw): + if not args: + col = None + elif len(args) == 1: + col = args[0] + else: + raise TypeError( + "update expected at most 1 arguments, got {}".format(len(args)) + ) + if self.__mutid == 0: raise ValueError('mutation {!r} has been finished'.format(self)) |