-
-
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
Ascola/add handler type aliases #5847
Ascola/add handler type aliases #5847
Conversation
Add a type alias for handlers to make it easier to annotate code which uses `aiohttp`.
Make use of added `Handler` type alias.
If you could have a quick search for places in the examples and tests where this annotation can be used, that would suffice for test coverage (as messing up the type would cause a mypy error in the example code). A couple of locations that look good:
aiohttp/tests/test_web_middleware.py Line 14 in 09ac1cb
|
Codecov Report
@@ Coverage Diff @@
## master #5847 +/- ##
==========================================
- Coverage 96.75% 96.75% -0.01%
==========================================
Files 44 44
Lines 9849 9848 -1
Branches 1591 1591
==========================================
- Hits 9529 9528 -1
Misses 182 182
Partials 138 138
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Hopefully someone else can take a quick look as well and approve.
Move the handler type alias import before declarations of other type aliases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Reasonable change, since typing in python becomes more and more common.
P.S. Maybe Middleware
object deserves its public type alias too.
_Middleware = Union[
Callable[[Request, Handler], Awaitable[StreamResponse]],
Callable[["Application", Handler], Awaitable[Handler]], # old-style
]
Backport to 3.8: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 1b45c73 on top of patchback/backports/3.8/1b45c733f07d59f9f56cf468b39cec109f745ff8/pr-5847 Backporting merged PR #5847 into master
🤖 @patchback |
@AustinScola @Dreamsorcerer could you backport this manually per the bot comment above? |
Sure thing |
* Add handler type alias (cherry picked from commit 1b45c73)
Fixed the conflicts for the backport and made PR #5861. |
What do these changes do?
aiohttp.typedefs.Handler
Handler
type alias in other parts of the packageAre there changes in behavior for the user?
Users can now use the type alias to annotate their code.
Related issue number
Issue #4686
Checklist
CONTRIBUTORS.txt
CHANGES
folder<issue_id>.<type>
for example (588.bugfix)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.