From: Daniele Varrazzo Date: Fri, 4 Jul 2025 23:24:11 +0000 (+0200) Subject: chore(json): adapt caching types definition to Python 3.8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1115%2Fhead;p=thirdparty%2Fpsycopg.git chore(json): adapt caching types definition to Python 3.8 --- diff --git a/psycopg/psycopg/types/json.py b/psycopg/psycopg/types/json.py index 6c93baf34..83ce719fa 100644 --- a/psycopg/psycopg/types/json.py +++ b/psycopg/psycopg/types/json.py @@ -8,7 +8,7 @@ from __future__ import annotations import json import logging -from types import CodeType +from types import CodeType # noqa[F401] from typing import Any, Callable from warnings import warn from threading import Lock @@ -22,7 +22,7 @@ from .._compat import TypeAlias JsonDumpsFunction: TypeAlias = Callable[[Any], "str | bytes"] JsonLoadsFunction: TypeAlias = Callable[["str | bytes"], Any] -_AdapterKey: TypeAlias = tuple[type, CodeType] +_AdapterKey: TypeAlias = "tuple[type, CodeType]" logger = logging.getLogger("psycopg") diff --git a/tests/types/test_json.py b/tests/types/test_json.py index faae9e662..2c670da88 100644 --- a/tests/types/test_json.py +++ b/tests/types/test_json.py @@ -269,7 +269,7 @@ def test_load_leak_with_local_functions(dsn, binary, pgtype, caplog): def register(conn: psycopg.Connection) -> None: - def f(x: str | bytes) -> Any: + def f(x: "str | bytes") -> Any: return json.loads(x) set_json_loads(f, conn)