Skip to content

Commit

Permalink
re-add kwargs to __new__
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Oct 6, 2023
1 parent edb93d8 commit 0f51415
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions immutabledict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def fromkeys(
) -> immutabledict[_K, _V]:
return cls(cls.dict_cls.fromkeys(seq, value))

def __new__(cls, *args: Any) -> immutabledict[_K, _V]:
def __new__(cls, *args: Any, **kwargs: Any) -> immutabledict[_K, _V]:
inst = super().__new__(cls)
setattr(inst, "_dict", cls.dict_cls(*args))
setattr(inst, "_dict", cls.dict_cls(*args, **kwargs))
setattr(inst, "_hash", None)
return inst

Expand Down
4 changes: 4 additions & 0 deletions tests/test_immutabledict.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ def test_performance(self, statement: str) -> None:

assert time_immutable < 1.2 * time_standard

def test_new_kwargs(self) -> None:
immutable_dict: immutabledict[str, str] = immutabledict(a="foo", b="bar")
assert immutable_dict == {"a": "foo", "b": "bar"}


class TestImmutableOrderedDict:
def test_ordered(self) -> None:
Expand Down

0 comments on commit 0f51415

Please sign in to comment.