MagicStack / MagicStack/asyncpg
Value yielded by PoolAcquireContext is mistyped by IDEs
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 8.1k
- Forks
- 468
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
- asyncpg version: 0.21.0
- PostgreSQL version: 12.5
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: No - Python version: 3.9.1
- Platform: Windows 10
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: Yes
- If you built asyncpg locally, which version of Cython did you use?: N/A
- Can the issue be reproduced under both asyncio and
uvloop?: N/A
Using PyCharm Professional 2020.2 by JetBrains, the typing of conn is interpreted incorrectly in the following expression:
pool = await asyncpg.create_pool('postgres://...')
async with pool.acquire() as conn:
await conn.execute(...)
Expected: asyncpg.Connection
Observed: typing.Any
Suggested remedy: Explicitly type PoolAcquireContext.connection as typing.Optional[Connection] and/or explicitly type PoolAcquireContext.pool as Pool.
Caveat: The suggestions above will break compatibility with Python 3.4, which reached end of life in March 2019.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne bei den Typdefinitionen von PoolAcquireContext und reproduziere das Beispiel pool.acquire() in PyCharm, um den abgeleiteten Typ von conn zu prüfen. Vergleiche die Annotationen für connection und pool mit dem angegebenen erwarteten Typ asyncpg.Connection und berücksichtige dabei den Kompatibilitätshinweis zu Python 3.4. Als erledigt gilt die Aufgabe, wenn die IDE conn korrekt ableitet, ohne die unterstützte Kompatibilität zu verlieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- postgresql, python
- Bereich
- databases
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100