Skip to content

Commit

Permalink
ignore python 3.7 error + docs
Browse files Browse the repository at this point in the history
  • Loading branch information
biniona committed Oct 7, 2024
1 parent dd19c1f commit cc4c5e9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions minject/asyncio_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"""

try:
from asyncio import to_thread
# Python 3.7 mypy raises attr-defined error for to_thread, so
# we must ignore it here.
from asyncio import to_thread # type: ignore[attr-defined]
# This is copy pasted from here: https://github.com/python/cpython/blob/03775472cc69e150ced22dc30334a7a202fc0380/Lib/asyncio/threads.py#L1-L25
except ImportError:
"""High-level support for working with threads in asyncio"""
Expand All @@ -20,8 +22,9 @@
# Minject Specific Edit: I removed the '/' from the function signature,
# as this is not supported in python 3.7 (added in python 3.8).
# The '/' forces that "func" be passed positionally (I.E. first argument
# to to_thread). Users of this extension must be careful to pass the
# function as the first argument.
# to to_thread). Users of this extension must be careful to pass the argument
# to "func" positionally, or there could be different behavior
# when using minject in python 3.7 and python 3.9+.
# original asyncio source: "async def to_thread(func, /, *args, **kwargs):"
async def to_thread(func, *args, **kwargs):
"""Asynchronously run function *func* in a separate thread.
Expand Down

0 comments on commit cc4c5e9

Please sign in to comment.