Skip to content

Commit

Permalink
Work around a mypy bug
Browse files Browse the repository at this point in the history
  • Loading branch information
A5rocks committed Feb 16, 2025
1 parent b81444d commit d3e7789
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/trio/_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,13 +1122,26 @@ class UnixRunProcessMixin(TypedDict, total=False):
check: bool
deliver_cancel: Callable[[Process], Awaitable[None]] | None

# TODO: once https://github.com/python/mypy/issues/18692 is
# fixed, move the `UnixRunProcessArgs` definition down.
if sys.version_info >= (3, 11):
UnixProcessArgs = UnixProcessArgs3_11

class UnixRunProcessArgs(UnixProcessArgs3_11, UnixRunProcessMixin):
pass

elif sys.version_info >= (3, 10):
UnixProcessArgs = UnixProcessArgs3_10

class UnixRunProcessArgs(UnixProcessArgs3_10, UnixRunProcessMixin):
pass

else:
UnixProcessArgs = UnixProcessArgs3_9

class UnixRunProcessArgs(UnixProcessArgs3_9, UnixRunProcessMixin):
pass

@overload # type: ignore[no-overload-impl]
async def open_process(
command: StrOrBytesPath,
Expand All @@ -1147,9 +1160,6 @@ async def open_process(
**kwargs: Unpack[UnixProcessArgs],
) -> trio.Process: ...

class UnixRunProcessArgs(UnixProcessArgs, UnixRunProcessMixin):
pass

@overload # type: ignore[no-overload-impl]
async def run_process(
command: StrOrBytesPath,
Expand Down

0 comments on commit d3e7789

Please sign in to comment.