Skip to content

Commit 064233c

Browse files
authored
Fix how status is inferenced in connection_summary
Hi! I am working on mypy in python/mypy#18797 And I've noticed a small thing in your code. Ideally, `SomeEnum.Item.name` should be inferenced as `Literal[NAME_ONE, NAME_TWO, ...]` But, since you later modify `status` (which is the name of a enum item), it should be explicitly annotated as `str`, not `Literal`.
1 parent 1b1c1d8 commit 064233c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: psycopg/psycopg/pq/misc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def connection_summary(pgconn: abc.PGconn) -> str:
153153
parts = []
154154
if pgconn.status == OK:
155155
# Put together the [STATUS]
156-
status = TransactionStatus(pgconn.transaction_status).name
156+
status: str = TransactionStatus(pgconn.transaction_status).name
157157
if pgconn.pipeline_status:
158158
status += f", pipeline={PipelineStatus(pgconn.pipeline_status).name}"
159159

0 commit comments

Comments
 (0)