From 284a68525a414c07a37626bebbb22c03fd1f4c68 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sat, 5 Jul 2025 01:24:11 +0200 Subject: [PATCH] chore(json): adapt caching types definition to Python 3.8 --- psycopg/psycopg/types/json.py | 4 ++-- tests/types/test_json.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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) -- 2.47.2