-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
tornado: add some types #5742
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
tornado: add some types #5742
Conversation
The stubtest failure seems to be due to an issue with PIL. I'll just push a fix. |
def acquire(self, timeout: Optional[Any] = ...): ... | ||
def __enter__(self): ... | ||
def __enter__(self) -> NoReturn: ... |
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.
The implementation is:
def __enter__(self) -> None:
raise RuntimeError("Use 'async with' instead of 'with' for Semaphore")
It might be better to delete this, so that you get an error when type-checking, not at runtime.
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.
Done
def __enter__(self) -> NoReturn: ... | ||
__exit__: Any | ||
def __aenter__(self): ... | ||
def __aexit__(self, typ, value, tb): ... | ||
def __aenter__(self) -> None: ... | ||
def __aexit__( | ||
self, typ: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[TracebackType] | ||
) -> None: ... |
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.
My comments for class Semaphore
apply here too.
Could you also update the version field in |
I set the version to 5.1, the last that actually supported Python 2. |
See https://github.com/tornadoweb/tornado/blob/master/tornado/locks.py
These stubs are for Python 2 only but include Python 3 annotations. See #5220 for context.
These were the only
__aenter__
stubs I could find that didn't already have correct annotations. I was auditing those as part of #5676.