From 0f37f156aa795c58cd3c323b9a0a8f8f3f7f19ac Mon Sep 17 00:00:00 2001 From: amirreza Date: Mon, 12 May 2025 12:39:54 +0330 Subject: [PATCH 1/2] remove the workaround for python 3.8 type checking --- asgiref/current_thread_executor.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/asgiref/current_thread_executor.py b/asgiref/current_thread_executor.py index 67a7926f..70097dd1 100644 --- a/asgiref/current_thread_executor.py +++ b/asgiref/current_thread_executor.py @@ -104,12 +104,5 @@ def _submit( # Return the future return f - # Python 3.9+ has a new signature for submit with a "/" after `fn`, to enforce - # it to be a positional argument. If we ignore[override] mypy on 3.9+ will be - # happy but 3.8 will say that the ignore comment is unused, even when - # defining them differently based on sys.version_info. - # We should be able to remove this when we drop support for 3.8. - if not TYPE_CHECKING: - - def submit(self, fn, *args, **kwargs): - return self._submit(fn, *args, **kwargs) + def submit(self, fn, *args, **kwargs): + return self._submit(fn, *args, **kwargs) From 502c78e32af6403445e290f4a84d6c52e0a6436d Mon Sep 17 00:00:00 2001 From: amirreza Date: Mon, 12 May 2025 12:40:21 +0330 Subject: [PATCH 2/2] make getattr more compact --- asgiref/local.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/asgiref/local.py b/asgiref/local.py index 7d228aeb..8f7855df 100644 --- a/asgiref/local.py +++ b/asgiref/local.py @@ -14,12 +14,8 @@ def __init__(self) -> None: def __getattr__(self, key: str) -> Any: try: var = self._data[key] - except KeyError: - raise AttributeError(f"{self!r} object has no attribute {key!r}") - - try: return var.get() - except LookupError: + except (KeyError, LookupError): raise AttributeError(f"{self!r} object has no attribute {key!r}") def __setattr__(self, key: str, value: Any) -> None: