Skip to content

psycopg2: fix types of getconn and conn parameter types in pool stubs#15704

Open
hugoivankm wants to merge 1 commit intopython:mainfrom
hugoivankm:fix-psycopg2-pool-connection-types
Open

psycopg2: fix types of getconn and conn parameter types in pool stubs#15704
hugoivankm wants to merge 1 commit intopython:mainfrom
hugoivankm:fix-psycopg2-pool-connection-types

Conversation

@hugoivankm
Copy link
Copy Markdown

AbstractConnectionPool.getconn was missing a return type annotation and putconn conn parameter was untyped, causing Pylance to report reportUnknownMemberType on both methods.

Fixed by:

  • Annotating getconn return type as connection
  • Annotating conn parameter as connection in AbstractConnectionPool.putconn
  • Annotating conn parameter as connection | None in ThreadedConnectionPool.putconn

Let me know if there is any issue.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Diff from mypy_primer, showing the effect of this PR on open source code:

pandas (https://github.com/pandas-dev/pandas)
- pandas/core/computation/ops.py:328: error: Need type annotation for "_binary_ops_dict" (hint: "_binary_ops_dict: dict[<type>, <type>] = ...")  [var-annotated]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant