From 4082746b35b0de4fdcc7e3b4bd6789a27fad652c Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Tue, 4 Jun 2024 09:33:34 +0200 Subject: [PATCH] chore: upgrade usage lru_cache decorator for Python 3.8+ --- docs/lib/libpq_docs.py | 2 +- psycopg/psycopg/_conninfo_utils.py | 2 +- psycopg/psycopg/_queries.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/lib/libpq_docs.py b/docs/lib/libpq_docs.py index 2868916f5..e072d0658 100644 --- a/docs/lib/libpq_docs.py +++ b/docs/lib/libpq_docs.py @@ -143,7 +143,7 @@ class LibpqReader: return self.app.config.libpq_docs_version -@lru_cache() +@lru_cache def get_reader(): return LibpqReader() diff --git a/psycopg/psycopg/_conninfo_utils.py b/psycopg/psycopg/_conninfo_utils.py index 68fb7b3a2..4e7025d3e 100644 --- a/psycopg/psycopg/_conninfo_utils.py +++ b/psycopg/psycopg/_conninfo_utils.py @@ -114,7 +114,7 @@ def get_param_def(keyword: str, _cache: dict[str, ParamDef] = {}) -> ParamDef | return _cache.get(keyword) -@lru_cache() +@lru_cache def is_ip_address(s: str) -> bool: """Return True if the string represent a valid ip address.""" try: diff --git a/psycopg/psycopg/_queries.py b/psycopg/psycopg/_queries.py index 537a65669..3368e79d1 100644 --- a/psycopg/psycopg/_queries.py +++ b/psycopg/psycopg/_queries.py @@ -228,7 +228,7 @@ def _query2pg_nocache( # records), and the resulting cache size is >100Mb. So, we will avoid to cache # large queries or queries with a large number of params. See # https://github.com/sqlalchemy/sqlalchemy/discussions/10270 -_query2pg = lru_cache()(_query2pg_nocache) +_query2pg = lru_cache(_query2pg_nocache) class PostgresClientQuery(PostgresQuery): @@ -326,7 +326,7 @@ def _query2pg_client_nocache( return b"".join(chunks), order, parts -_query2pg_client = lru_cache()(_query2pg_client_nocache) +_query2pg_client = lru_cache(_query2pg_client_nocache) _re_placeholder = re.compile( -- 2.47.2