Skip to content

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

Merged
merged 7 commits into from
Jul 11, 2021
Merged

tornado: add some types #5742

merged 7 commits into from
Jul 11, 2021

Conversation

JelleZijlstra
Copy link
Member

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.

@JelleZijlstra
Copy link
Member Author

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: ...
Copy link
Collaborator

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 43 to 48
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: ...
Copy link
Collaborator

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.

@Akuli Akuli mentioned this pull request Jul 9, 2021
@srittau
Copy link
Collaborator

srittau commented Jul 9, 2021

Could you also update the version field in METADATA.toml while you're here?

@JelleZijlstra
Copy link
Member Author

I set the version to 5.1, the last that actually supported Python 2.

@srittau srittau merged commit a90573f into python:master Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants