-
-
Notifications
You must be signed in to change notification settings - Fork 506
Standardize all context manager __exit__ methods #1194
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
@@ -1,5 +1,4 @@ | |||
import os |
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.
unused import
def message(self): ... | ||
def __enter__(self): ... | ||
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any): ... | ||
def test(self) -> 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.
def __enter__(self): ... | ||
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any): ... | ||
def test(self) -> None: ... | ||
def message(self) -> str: ... |
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.
Removed in Django 4.1, but previously returned a str
: django/django@806efe9#diff-7833da5b45a68d00834388d97dd5c4413e3796497c7bc5e0cc2621b08a2d0df1L111
exc_type: Optional[Type[BaseException]], | ||
exc_value: Optional[BaseException], | ||
traceback: Optional[TracebackType], | ||
) -> Optional[bool]: ... |
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.
@@ -1,5 +1,5 @@ | |||
from types import TracebackType | |||
from typing import Any, Dict, Iterable, Iterator, List, Optional, Type |
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.
unused import
@@ -1,4 +1,4 @@ | |||
from contextlib import ContextDecorator, contextmanager |
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.
unused import
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.
Thanks! Good stuff
I have made things!
The Django-MySQL test suite uses a subclass of
CaptureQueriesContext
, which is how I found its__exit__()
method was mistyped. This PR standardizes all__exit__
methods to use the correct optional types, and fixes some minor issues on the way.Related issues
n/a