Minor style improvements to keep ruff happy.
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 31c5680..c111e54 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -25,5 +25,4 @@ ```python import cachetools - ```
diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9dddde8..29e5ae8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst
@@ -1,3 +1,9 @@ +v7.1.6 (2026-07-24) +=================== + +- Minor style improvements to keep ``ruff`` happy. + + v7.1.5 (2026-07-23) ===================
diff --git a/docs/conf.py b/docs/conf.py index 1df786b..f92c699 100644 --- a/docs/conf.py +++ b/docs/conf.py
@@ -1,6 +1,5 @@ import importlib.metadata - project = "cachetools" copyright = "2014-2026 Thomas Kemmer" release = importlib.metadata.version(project)
diff --git a/pyproject.toml b/pyproject.toml index 8554d13..3698f37 100644 --- a/pyproject.toml +++ b/pyproject.toml
@@ -52,3 +52,6 @@ reportFunctionMemberAccess = "information" reportOptionalContextManager = "warning" reportOptionalMemberAccess = "warning" + +[tool.ruff.lint] +ignore = ["DTZ005", "UP031"]
diff --git a/src/cachetools/__init__.py b/src/cachetools/__init__.py index a1604e9..2031731 100644 --- a/src/cachetools/__init__.py +++ b/src/cachetools/__init__.py
@@ -12,7 +12,7 @@ "cachedmethod", ) -__version__ = "7.1.5" +__version__ = "7.1.6" import collections import collections.abc @@ -53,8 +53,8 @@ if getsizeof: self.getsizeof = getsizeof if self.getsizeof is not Cache.getsizeof: - self.__size = dict() - self.__data = dict() + self.__size = {} + self.__data = {} self.__currsize = 0 self.__maxsize = maxsize @@ -447,7 +447,7 @@ """LRU Cache implementation with per-item time-to-live (TTL) value.""" class _Link: - __slots__ = ("key", "expires", "next", "prev") + __slots__ = ("expires", "key", "next", "prev") def __init__(self, key=None, expires=None): self.key = key @@ -591,7 +591,7 @@ @functools.total_ordering class _Item: - __slots__ = ("key", "expires", "removed") + __slots__ = ("expires", "key", "removed") def __init__(self, key=None, expires=None): self.key = key
diff --git a/src/cachetools/func.py b/src/cachetools/func.py index c2d3efc..07116bd 100644 --- a/src/cachetools/func.py +++ b/src/cachetools/func.py
@@ -7,9 +7,7 @@ import time from threading import Condition -from . import FIFOCache, LFUCache, LRUCache, RRCache, TTLCache -from . import cached -from . import keys +from . import FIFOCache, LFUCache, LRUCache, RRCache, TTLCache, cached, keys class _UnboundTTLCache(TTLCache):
diff --git a/src/cachetools/keys.pyi b/src/cachetools/keys.pyi index bbc2a80..da9c809 100644 --- a/src/cachetools/keys.pyi +++ b/src/cachetools/keys.pyi
@@ -1,7 +1,8 @@ -from _typeshed import Unused from collections.abc import Hashable from typing import Final +from _typeshed import Unused + __all__: Final = ("hashkey", "methodkey", "typedkey", "typedmethodkey") def hashkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ...
diff --git a/tests/test_cached.py b/tests/test_cached.py index 25b2e06..70a26b9 100644 --- a/tests/test_cached.py +++ b/tests/test_cached.py
@@ -345,7 +345,7 @@ class DictWrapperTest(unittest.TestCase, DecoratorTestMixin): def cache(self, minsize): - return dict() + return {} def test_decorator_info(self): cache = self.cache(2)
diff --git a/tests/test_cachedmethod.py b/tests/test_cachedmethod.py index 745364b..8d519f6 100644 --- a/tests/test_cachedmethod.py +++ b/tests/test_cachedmethod.py
@@ -2,7 +2,6 @@ import unittest.mock import warnings - from cachetools import Cache, cachedmethod, keys from . import CountedCondition, CountedLock, _TestCaseProtocol @@ -636,7 +635,7 @@ class DictMethodTest(unittest.TestCase, MethodDecoratorTestMixin): def cache(self, minsize, **_kwargs): - return dict() + return {} class WeakRefMethodTest(unittest.TestCase):
diff --git a/tests/test_func.py b/tests/test_func.py index 924445d..e02c5fd 100644 --- a/tests/test_func.py +++ b/tests/test_func.py
@@ -1,5 +1,6 @@ import unittest -from typing import Any, Callable +from collections.abc import Callable +from typing import Any import cachetools.func
diff --git a/tests/test_rr.py b/tests/test_rr.py old mode 100755 new mode 100644
diff --git a/tests/test_threading.py b/tests/test_threading.py index 734028b..56995a3 100644 --- a/tests/test_threading.py +++ b/tests/test_threading.py
@@ -54,7 +54,7 @@ def test_cached_stampede(self): global count count = 0 - threads = [threading.Thread(target=func) for i in range(0, self.NTHREADS)] + threads = [threading.Thread(target=func) for i in range(self.NTHREADS)] for t in threads: t.start() for t in threads: @@ -70,9 +70,7 @@ def test_cachedmethod_stampede(self): self.cache = LRUCache(1) self.count = 0 - threads = [ - threading.Thread(target=self.method) for i in range(0, self.NTHREADS) - ] + threads = [threading.Thread(target=self.method) for i in range(self.NTHREADS)] for t in threads: t.start() for t in threads: @@ -88,9 +86,7 @@ def test_cached_locked(self): global count count = 0 - threads = [ - threading.Thread(target=locked_func) for i in range(0, self.NTHREADS) - ] + threads = [threading.Thread(target=locked_func) for i in range(self.NTHREADS)] for t in threads: t.start() for t in threads: @@ -109,7 +105,7 @@ self.cache = LRUCache(1) self.count = 0 threads = [ - threading.Thread(target=self.locked_method) for i in range(0, self.NTHREADS) + threading.Thread(target=self.locked_method) for i in range(self.NTHREADS) ] for t in threads: t.start()
diff --git a/tox.ini b/tox.ini index 8670b2a..d026dd9 100644 --- a/tox.ini +++ b/tox.ini
@@ -31,11 +31,9 @@ ruff commands = ruff check {posargs} -skip_install = true [testenv:ruff-format] deps = ruff commands = ruff format --diff -q {posargs} -skip_install = true