Skip to content

Commit

Permalink
Update combomethod type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
darwintree committed Nov 17, 2022
1 parent 7b023a0 commit b9a4b05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions eth_utils/decorators.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import functools
import itertools
from typing import Any, Callable, Dict, Type, TypeVar
from typing import Any, Callable, Dict, Generic, Type, TypeVar, Union
from typing_extensions import Concatenate, ParamSpec

from .types import is_text

T = TypeVar("T")
P = ParamSpec("P")


class combomethod(object):
def __init__(self, method: Callable[..., Any]) -> None:
class combomethod(Generic[P, T], object):
def __init__(self, method: Callable[Concatenate[Any, P], T]) -> None:
self.method = method

def __get__(self, obj: T = None, objtype: Type[T] = None) -> Callable[..., Any]:
def __get__(
self, obj: object = None, objtype: Union[type, None] = None
) -> Callable[P, T]:
@functools.wraps(self.method)
def _wrapper(*args: Any, **kwargs: Any) -> Any:
def _wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
if obj is not None:
return self.method(obj, *args, **kwargs)
else:
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"black>=18.6b4,<19",
"flake8==3.7.9",
"isort>=4.2.15,<5",
"mypy==0.910",
"mypy==0.971",
"pydocstyle>=5.0.0,<6",
"pytest>=6.2.5,<7",
"types-setuptools",
Expand Down Expand Up @@ -67,6 +67,7 @@
"eth-typing>=3.0.0,<4.0.0",
"toolz>0.8.2,<1;implementation_name=='pypy'",
"cytoolz>=0.10.1,<1.0.0;implementation_name=='cpython'",
"typing-extensions>=4.1.0",
],
python_requires=">=3.6,<4",
extras_require=extras_require,
Expand Down

0 comments on commit b9a4b05

Please sign in to comment.