Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type hints to psycopg #3067

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Kludex
Copy link
Contributor

@Kludex Kludex commented Dec 4, 2024

@xrmx xrmx added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Dec 5, 2024
@Kludex
Copy link
Contributor Author

Kludex commented Dec 5, 2024

Is it a docstring error?

@Kludex Kludex changed the title Add type hints to Psycopg Add type hints to psycopg Dec 10, 2024
@Kludex Kludex requested a review from a team as a code owner December 12, 2024 09:10
Comment on lines +121 to +124
ConnectionT = TypeVar(
"ConnectionT", psycopg.Connection, psycopg.AsyncConnection
)
CursorT = TypeVar("CursorT", psycopg.Cursor, psycopg.AsyncCursor)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to make sure that the output value of a function that accepts ConnectionT is also a ConnectionT... Doing what I'm doing here, I'm telling the type checker if the class is a psycopg.Connection, the output will be a psycopg.Connection. That's why we don't use Unions here.

@Kludex
Copy link
Contributor Author

Kludex commented Dec 12, 2024

Anything I can do to speed up the review process here? @xrmx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants