Skip to content

Commit

Permalink
Fixed a bug causing cache() to raise a TypeError when attempting …
Browse files Browse the repository at this point in the history
…to cache a function call that contains an argument that is a list containing a dictionary (#3).
  • Loading branch information
umarbutler committed Mar 20, 2024
1 parent 059d548 commit ec07874
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## Changelog 🔄
All notable changes to `persist-cache` will be documented here. This project adheres to [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.1] - 2024-03-20
### Fixed
- Fixed a bug causing `cache()` to raise a `TypeError` when attempting to cache a function call that contains an argument that is a list containing a dictionary ([#3](https://github.com/umarbutler/persist-cache/issues/3)) ([fe7aa6c](https://github.com/umarbutler/persist-cache/commit/fe7aa6ccd2f7fbeebaa53e4c1cc0230f6ef35cb4)).

## [0.3.0] - 2024-03-19
### Changed
- Ceased delimiting hashes and the length of the input with hyphens as the hashes already have a fixed size so there is no possibility of collision.
Expand Down
2 changes: 1 addition & 1 deletion src/persist_cache/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def directly_msgpackable(data: Any) -> bool:
# - It is of a type specified by `ABSOLUTELY_DIRECTLY_MSGPACKABLE_TYPES`.
if (isinstance(data, str) and not any(data.startswith(str_signature) for str_signature in STR_SIGNATURES)) \
or isinstance(data, int) and -2**63 <= data <= 2**64-1 \
or (isinstance(data, list) and all(directly_msgpackable(d) for d in data) and (len(data) == 0 or data[0] not in LISTED_SIGNATURES)) \
or (isinstance(data, list) and all(directly_msgpackable(d) for d in data) and (len(data) == 0 or not isinstance(data[0], str) or data[0] not in LISTED_SIGNATURES)) \
or (isinstance(data, dict) and all(directly_msgpackable(k) and directly_msgpackable(v) for k, v in data.items())) \
or isinstance(data, ABSOLUTELY_DIRECTLY_MSGPACKABLE_TYPES):
return True
Expand Down

0 comments on commit ec07874

Please sign in to comment.