-
Notifications
You must be signed in to change notification settings - Fork 3
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
Should await asyncpg.create_pool()
return Pool
instead of None | Pool
#120
Comments
I think you're right that |
By way of example, if import asyncpg
async def main() -> None:
pool = await asyncpg.create_pool()
reveal_type(pool) # Pool[Record]
reveal_type(await pool) # Pool[Record] | None |
I changed the typing of |
Evidently, I didn't take into account using |
I'm showing up late to the party. I've been down a rabbit hole lately because I seem to have a calling stack that While I'm getting to the bottom of why I have the extra await in there, I have a workaround like so,
But I'm wondering, in case the pool is already initialized, how come it has to return |
And now I see there's a fix in the latest version. Never mind then. For anyone tuning in, upgrade to the latest version. |
Thank you for the library!
After setting this up I found that my connection pool logic is being flagged
essentially I have:
and I get an error:
looking at Asyncpg's pool:
https://github.com/MagicStack/asyncpg/blob/40b16ea65f8b634a392e7e5b6509ee7dda45c4cd/asyncpg/pool.py#L978-L979
I think technically it can return
None
but it seems unlikely to happen for most use cases (maybe?)so while
Pool | None
represents a possible case, I think it would be okay if it didn't include it in the types for better ergonomicsWhat do you think?
The text was updated successfully, but these errors were encountered: