Skip to content

Commit c6cea81

Browse files
committed
Fix flake8 issues in reawaitable.py by using Literal instead of Enum
1 parent a9b0c38 commit c6cea81

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

returns/primitives/reawaitable.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,38 @@ async def __aexit__(self, exc_type, exc_val, exc_tb) -> None: ...
1818
AsyncContext = Literal["asyncio", "trio", "unknown"]
1919

2020

21-
# Check for anyio and trio availability
22-
try:
23-
import anyio # pragma: no qa
21+
def _is_anyio_available() -> bool:
22+
"""Check if anyio is available.
2423
25-
has_anyio = True
24+
Returns:
25+
bool: True if anyio is available
26+
"""
2627
try:
27-
import trio # pragma: no qa
28+
import anyio # pragma: no cover
29+
except ImportError: # pragma: no cover
30+
return False
31+
return True
32+
33+
34+
def _is_trio_available() -> bool:
35+
"""Check if trio is available.
36+
37+
Returns:
38+
bool: True if trio is available
39+
"""
40+
if not _is_anyio_available():
41+
return False
2842

29-
has_trio = True
43+
try:
44+
import trio # pragma: no cover
3045
except ImportError: # pragma: no cover
31-
has_trio = False
32-
except ImportError: # pragma: no cover
33-
has_anyio = False
34-
has_trio = False
46+
return False
47+
return True
48+
49+
50+
# Set availability flags at module level
51+
has_anyio = _is_anyio_available()
52+
has_trio = _is_trio_available()
3553

3654

3755
def _is_in_trio_context() -> bool:

0 commit comments

Comments
 (0)