Skip to content

Commit

Permalink
Properly implement the overload decorator
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
  • Loading branch information
noxdafox committed Nov 21, 2024
1 parent 8520472 commit 49c2ec5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 31 deletions.
9 changes: 2 additions & 7 deletions pebble/asynchronous/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from itertools import count
from functools import wraps
from concurrent.futures import TimeoutError
from typing import Any, Callable, Optional, Union, overload
from typing import Any, Callable, Optional, overload

from pebble import common
from pebble.pool.process import ProcessPool
Expand All @@ -33,7 +33,6 @@ def process(
func: Callable[[common.P], common.T]
) -> Callable[[common.P], asyncio.Future[common.T]]:
...

@overload
def process(
name: Optional[str] = None,
Expand All @@ -44,11 +43,7 @@ def process(
) -> Callable[[Callable[[common.P], common.T]],
Callable[[common.P], asyncio.Future[common.T]]]:
...

def process(
*args: list,
**kwargs: dict
) -> Callable:
def process(*args, **kwargs):
"""Runs the decorated function in a concurrent process,
taking care of the result and error management.
Expand Down
9 changes: 2 additions & 7 deletions pebble/asynchronous/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import asyncio

from functools import wraps
from typing import Callable, Optional, Union, overload
from typing import Callable, Optional, overload

from pebble import common
from pebble.pool.thread import ThreadPool
Expand All @@ -28,7 +28,6 @@ def thread(
func: Callable[[common.P], common.T]
) -> Callable[[common.P], asyncio.Future[common.T]]:
...

@overload
def thread(
name: Optional[str] = None,
Expand All @@ -37,11 +36,7 @@ def thread(
) -> Callable[[Callable[[common.P], common.T]],
Callable[[common.P], asyncio.Future[common.T]]]:
...

def thread(
*args: list,
**kwargs: dict
) -> Callable:
def thread(*args, **kwargs):
"""Runs the decorated function within a concurrent thread,
taking care of the result and error management.
Expand Down
11 changes: 2 additions & 9 deletions pebble/concurrent/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from itertools import count
from functools import wraps
from typing import Any, Callable, Optional, Union, overload
from typing import Any, Callable, Optional, overload
from concurrent.futures import CancelledError, TimeoutError

from pebble import common
Expand All @@ -33,7 +33,6 @@ def process(
func: Callable[[common.P], common.T]
) -> Callable[[common.P], common.ProcessFuture[common.T]]:
...

@overload
def process(
name: Optional[str] = None,
Expand All @@ -44,13 +43,7 @@ def process(
) -> Callable[[Callable[[common.P], common.T]],
Callable[[common.P], common.ProcessFuture[common.T]]]:
...

def process(
*args: list,
**kwargs: dict
) -> Union[Callable[[common.P], common.ProcessFuture[common.T]],
Callable[[Callable[[common.P], common.T]],
Callable[[common.P], common.ProcessFuture[common.T]]]]:
def process(*args, **kwargs):
"""Runs the decorated function in a concurrent process,
taking care of the result and error management.
Expand Down
9 changes: 1 addition & 8 deletions pebble/concurrent/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def thread(
func: Callable[[common.P], common.T]
) -> Callable[[common.P], Future[common.T]]:
...

@overload
def thread(
name: Optional[str] = None,
Expand All @@ -35,13 +34,7 @@ def thread(
) -> Callable[[Callable[[common.P], common.T]],
Callable[[common.P], Future[common.T]]]:
...

def thread(
*args: list,
**kwargs: dict
) -> Union[Callable[[common.P], Future[common.T]],
Callable[[Callable[[common.P], common.T]],
Callable[[common.P], Future[common.T]]]]:
def thread(*args, **kwargs):
"""Runs the decorated function within a concurrent thread,
taking care of the result and error management.
Expand Down

0 comments on commit 49c2ec5

Please sign in to comment.