Skip to content

Commit

Permalink
Merge branch 'master' into set_delete
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Oct 16, 2023
2 parents 90daf44 + bdf02ce commit ed9759d
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 43 deletions.
3 changes: 1 addition & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
ko_fi: corenting
custom: ["https://www.buymeacoffee.com/corenting"]
custom: ["https://corenting.fr/donate"]
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Version 3.1.0

- Replace `__init__` by `__new__`. Thanks to [@spacether](https://github.com/spacether) for the [PR #263](https://github.com/corenting/immutabledict/pull/263)
- Add explicit items()/keys()/values() methods to speedup these methods. Thanks to [@matthiasdiener](https://github.com/matthiasdiener) for the [PR #265](https://github.com/corenting/immutabledict/pull/265)

# Version 3.0.0

- `copy()` (**breaking change**): remove the option to pass keyword arguments (which were present as key/value pairs in the copy). Now the method doesn't take any arguments (it behaves the same as a normal `dict`).
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,4 @@ print(my_item["a"]) # Print "value"

## Donations

If you wish to support the project, donations are possible on the following platforms:
- [ko-fi](https://ko-fi.com/corenting)
- [buymeacoffee](https://www.buymeacoffee.com/corenting)
If you wish to support the app, donations are possible [here](https://corenting.fr/donate).
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
95 changes: 59 additions & 36 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include = [
[tool.poetry.urls]
"Changelog" = "https://github.com/corenting/immutabledict/blob/master/CHANGELOG.md"
"Bug Tracker" = "https://github.com/corenting/immutabledict/issues"
"Donation" = "https://corenting.fr/donate"

[tool.poetry.dependencies]
python = "^3.8"
Expand Down
4 changes: 4 additions & 0 deletions tests/test_immutabledict.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ def test_set_delete_update(self) -> None:
# Make sure d doesn't change
assert d == immutabledict(a=1, b=2) == dict(a=1, b=2)

def test_new_kwargs(self) -> None:
immutable_dict: immutabledict[str, int] = immutabledict(a=1, b=2)
assert immutable_dict == {"a": 1, "b": 2} == dict(a=1, b=2)


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

0 comments on commit ed9759d

Please sign in to comment.