Skip to content

Commit

Permalink
Fix issues with caching internal function calls (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasisz authored Jul 17, 2024
1 parent 10a9ec4 commit 45c2993
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

Nothing yet.
- Fix issues with caching internal function calls

## [1.8.1] - 2023-05-12

Expand Down
2 changes: 1 addition & 1 deletion dacite/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@lru_cache(maxsize=None)
def cache(function: T) -> T:
return lru_cache(maxsize=get_cache_size())(function) # type: ignore
return lru_cache(maxsize=get_cache_size(), typed=True)(function) # type: ignore


def set_cache_size(size: Optional[int]) -> None:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,8 @@ class FakeType:
_special = True

assert extract_generic(FakeType, defaults) == defaults


def test_optional_and_union_none_does_not_pollute_scope_via_caching():
is_generic(Optional[str])
is_generic_collection(str | None)

0 comments on commit 45c2993

Please sign in to comment.