]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
fix: fix `status` annotation in `connection_summary`
authorsobolevn <mail@sobolevn.me>
Thu, 13 Mar 2025 10:40:42 +0000 (13:40 +0300)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 14 Mar 2025 10:53:03 +0000 (11:53 +0100)
Currently enum names are strings, but this is being changed to become
Literal. When this will happen, the type inferred will not be valid
anymore, as we mutate it and manipulate it as string in the function.

See https://github.com/python/mypy/pull/18797

psycopg/psycopg/pq/misc.py

index 1decf4b79824e3ae9c0bd0c0f0dc1160205e7ac2..31be494a0fa0d982c877b18c99cf51d3637a3726 100644 (file)
@@ -153,7 +153,7 @@ def connection_summary(pgconn: abc.PGconn) -> str:
     parts = []
     if pgconn.status == OK:
         # Put together the [STATUS]
-        status = TransactionStatus(pgconn.transaction_status).name
+        status: str = TransactionStatus(pgconn.transaction_status).name
         if pgconn.pipeline_status:
             status += f", pipeline={PipelineStatus(pgconn.pipeline_status).name}"