From bb228f1929056020904c7793d4d73e849c93e067 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Tue, 9 Jun 2026 12:51:25 +0200 Subject: [PATCH] App: Replace @lru_cache() with @cache Replace the @functools.lru_cache(maxsize=None) decorator with @functools.cache throughout App. functools.cache is a shorthand for functools.lru_cache(maxsize=None) introduced in Python 3.9 and is more concise and readable with identical behaviour. Signed-off-by: Jan Lindemann --- src/python/jw/pkg/App.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/python/jw/pkg/App.py b/src/python/jw/pkg/App.py index 9dfbd118..ccba3931 100644 --- a/src/python/jw/pkg/App.py +++ b/src/python/jw/pkg/App.py @@ -10,7 +10,7 @@ import re import sys from enum import Enum, auto -from functools import lru_cache +from functools import cache from typing import TYPE_CHECKING from .lib.App import App as Base @@ -512,7 +512,7 @@ class App(Base): def strip_module_from_spec(self, mod): return re.sub(r'-dev$|-devel$|-run$', '', re.split('([=><]+)', mod)[0].strip()) - @lru_cache(maxsize = None) + @cache def get_section(self, path: str, section: str) -> str: ret = '' pat = '[' + section + ']' @@ -529,7 +529,7 @@ class App(Base): file.close() return ret.rstrip() - @lru_cache(maxsize = None) + @cache def read_value(self, path: str, section: str, key: str) -> str | None: def scan_section(f, key: str) -> str | None: @@ -582,7 +582,7 @@ class App(Base): return 'none' return None - @lru_cache(maxsize = None) + @cache def get_value(self, project: str, section: str, key: str) -> str | None: ret: str | None proj_dir = self.__proj_dir(project, pretty = False) @@ -612,7 +612,7 @@ class App(Base): ) return ret - @lru_cache(maxsize = None) + @cache def get_version(self, project) -> str: ret = self.get_value(project, 'version', '') if ret is None: