pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/MagicStack/asyncpg/pull/1270

ull-requests-be6017ec12798e73.css" /> Add return type to PoolAcquireContext.__aenter__ and rename attribute by TerSent · Pull Request #1270 · MagicStack/asyncpg · GitHub
Skip to content

Add return type to PoolAcquireContext.__aenter__ and rename attribute - #1270

Open
TerSent wants to merge 1 commit into
MagicStack:masterfrom
TerSent:fix/pool-acquire-typing
Open

Add return type to PoolAcquireContext.__aenter__ and rename attribute#1270
TerSent wants to merge 1 commit into
MagicStack:masterfrom
TerSent:fix/pool-acquire-typing

Conversation

@TerSent

@TerSent TerSent commented Aug 16, 2025

Copy link
Copy Markdown

Summary

Improves type inference in async with pool.acquire() by:

  1. Adding -> connection.Connection return type to PoolAcquireContext.__aenter__
  2. Renaming internal attribute self.connection to self._conn to avoid confusion and help type checkers

Motivation

Without this change, type checkers (mypy, pyright, pylance) cannot correctly infer the type of the connection in:

async with pool.acquire() as conn:
    await conn.fetchrow("SELECT 1")  # ← conn has type 'Unknown' or 'Any'

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

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy