Skip to content

Conversation

adamchainz
Copy link
Contributor

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

@adamchainz adamchainz requested a review from sobolevn October 19, 2022 08:56
@@ -1,5 +1,4 @@
import os
Copy link
Contributor Author

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

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

Choose a reason for hiding this comment

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

exc_type: Optional[Type[BaseException]],
exc_value: Optional[BaseException],
traceback: Optional[TracebackType],
) -> Optional[bool]: ...
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unused import

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thanks! Good stuff

@adamchainz adamchainz merged commit 36002a2 into typeddjango:master Oct 19, 2022
@adamchainz adamchainz deleted the exit_methods branch October 19, 2022 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants