Skip to content

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

Merged
srittau merged 1 commit intopython:mainfrom
hugoivankm:fix-psycopg2-pool-connection-types
May 8, 2026
Merged

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

Conversation

@hugoivankm
Copy link
Copy Markdown
Contributor

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]

Copy link
Copy Markdown
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@srittau srittau merged commit d2670db into python:main May 8, 2026
39 checks passed
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.

2 participants