Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add type for pool.acquire() #521

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

Open
Tynukua wants to merge 3 commits into MagicStack:master
base: master
Choose a base branch
Loading
from Tynukua:patch-1
Open

add type for pool.acquire() #521

Tynukua wants to merge 3 commits into MagicStack:master from Tynukua:patch-1

Conversation

Copy link

@Tynukua Tynukua commented Jan 8, 2020

No description provided.

eirnym and Yrlish reacted with thumbs up emoji
Copy link

eirnym commented Jan 10, 2020

Looks good for me.

@@ -566,7 +566,7 @@ async def fetchrow(self, query, *args, timeout=None):
async with self.acquire() as con:
return await con.fetchrow(query, *args, timeout=timeout)

def acquire(self, *, timeout=None):
def acquire(self, *, timeout=None) -> connection.Connection:
Copy link
Contributor

@and-semakin and-semakin Jun 22, 2021

Choose a reason for hiding this comment

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

This type hint only covers usual await case:

con = await pool.acquire()

But won't work properly for context manager case:

async with pool.acquire() as con:
 await con.execute(...)

The more correct return type could be something like PoolAcquireContext but we should check if mypy understands it first.

Copy link
Contributor

@and-semakin and-semakin Jun 22, 2021

Choose a reason for hiding this comment

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

#577 contains more precise types

Copy link
Contributor

It is clear that this is incorrect and should be PoolAcquireContext.

I'd suggest either changing that in this PR or just closing this and wait until a PR that targets more of these simple methods is created.

Copy link
Contributor

This is superseded by #1209

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

@and-semakin and-semakin and-semakin left review comments

@eirnym eirnym eirnym approved these changes

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /