-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Easy way to get common types for annotations #4686
Comments
You can define all types in your code using public classes: from aiohttp import web
Handler = Callable[[web.Request], Awaitable[web.StreamResponse]] But, I think, that defining a common combination of types will improve the user experience of working with a library |
That is also possible, but seems even less maintainable than importing protected variables. Hardcoded types in my code is more difficult to ensure they are correct and that they get updated if the signatures change in future. |
Can add +1 here. In my aiohttp libraries, such as aiohttp-middlewares I’m importing While, in reality I would like to have ability to import from aiohttp.web_typing import Handler, Middleware # and so on Or from ps. As implementation reference there is a pyrsistent.typing module, which provides type annotations for |
We've added the Handler type now. |
🐣 Is your feature request related to a problem? Please describe.
I'm unclear what the best way currently is to make use of type annotations in my own aiohttp projects.
💡 Describe the solution you'd like
One of the aiohttp-demos to be updated with full type hinting to serve as an example.
❓ Describe alternatives you've considered
The only way I can see at the moment, is with importing protected objects from various modules.
e.g.
from aiohttp.web_app import _Handler
though this is also in
aiohttp.web_urldispatcher._WebHandler
Types to add:
The text was updated successfully, but these errors were encountered: