You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The async/sync dichotomy of the library makes mypy go crazy. Usually, the first definition of a symbol wins. For example, in auth/session.py:
Incompatible types in assignment (expression has type "ClientSession", variable has type "Optional[Session]")
This is because Session is defined by the first import as from requests import Session (and the second definition as from aiohttp import ClientSession as Session is ignored).
The worst thing is that these errors propagated to the user side too. for example, Storage accepts session argument which is the same Session type as in the previous example. That means, when I try to pass aiohttp.ClientSession into Storage, I get a mypy error.
I can try fixing it by separating async and sync implementations a bit more and throwing a few Union 's in annotations if you're interested.
The text was updated successfully, but these errors were encountered:
Yeah, the metaprogramming stuff we've done to support the async/sync split definitely doesn't play nicely with mypy's assumptions. I'd be happy to accept any PRs to improve this sort of thing! The only area I'd want to call out is that our main goal is to avoid needing to "build the same thing twice" across versions; so long as any refactors you suggest keep in this theme, I'm happy :)
Other than that, please be aware that it's easier for us to review and merge smaller PRs -- a single refactor PR which replaces "everything" will take us much longer to work through.
The async/sync dichotomy of the library makes mypy go crazy. Usually, the first definition of a symbol wins. For example, in
auth/session.py
:This is because
Session
is defined by the first import asfrom requests import Session
(and the second definition asfrom aiohttp import ClientSession as Session
is ignored).The worst thing is that these errors propagated to the user side too. for example,
Storage
acceptssession
argument which is the sameSession
type as in the previous example. That means, when I try to passaiohttp.ClientSession
intoStorage
, I get a mypy error.I can try fixing it by separating async and sync implementations a bit more and throwing a few
Union
's in annotations if you're interested.The text was updated successfully, but these errors were encountered: