-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: improve type hints #2867
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
Conversation
|
Can we enforce those via ruff? |
Kludex
left a comment
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.
If you can find ruff rules to enforce this behavior, I'm happy to accept it.
|
Run A mini demo to verify: # bb.py
import typing
from typing import Callable, ContextManager, Sequence
def foo(a: Callable, b: ContextManager, c: Sequence) -> tuple[typing.Sequence, typing.ContextManager]:
passRun Then run import typing
from collections.abc import Sequence
from typing import Callable, ContextManager
def foo(a: Callable, b: ContextManager, c: Sequence) -> tuple[typing.Sequence, typing.ContextManager]:
pass |
Yes, |
But you replaced everything in this PR manually... Right? The diff duplicated since last time I checked. |
dcb657e to
7aefc73
Compare
|
@Kludex I use the following script to replace everything: Command line is: |
|
I guess it's time to do this. It will make the code shorter, and more readable - also updating the packages to use btw, same PR welcome on uvicorn if you are up to it. 😅 |
Kludex/uvicorn#2638 |
Summary
Only improve type hints, does not change any logic
ruff check --fix starlette testsfrom typing import ContextManager-->from contextlib import AbstractContextManagerChecklist