Skip to content

Commit 45c2993

Browse files
authored
Fix issues with caching internal function calls (#258)
1 parent 10a9ec4 commit 45c2993

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
Nothing yet.
10+
- Fix issues with caching internal function calls
1111

1212
## [1.8.1] - 2023-05-12
1313

dacite/cache.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

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

1313

1414
def set_cache_size(size: Optional[int]) -> None:

tests/test_types.py

+5
Original file line numberDiff line numberDiff line change
@@ -399,3 +399,8 @@ class FakeType:
399399
_special = True
400400

401401
assert extract_generic(FakeType, defaults) == defaults
402+
403+
404+
def test_optional_and_union_none_does_not_pollute_scope_via_caching():
405+
is_generic(Optional[str])
406+
is_generic_collection(str | None)

0 commit comments

Comments
 (0)