]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
fix: fix `status` annotation in `connection_summary` 1023/head
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:45:33 +0000 (11:45 +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 fe06141c2205671e1da76efc319253edea7092ab..92352a40d7e7641e4e9d745792d742252164429f 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}"