Skip to content

Commit

Permalink
WIP: MyPy all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers committed Dec 7, 2023
1 parent 9152728 commit b99c901
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 163 deletions.
4 changes: 2 additions & 2 deletions freezegun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
:copyright: (c) 2012 by Steve Pulec.
"""
from .api import freeze_time
from .config import configure
from .api import freeze_time as freeze_time
from .config import configure as configure

__title__ = 'freezegun'
__version__ = '1.3.1'
Expand Down
2 changes: 0 additions & 2 deletions freezegun/__init__.pyi

This file was deleted.

14 changes: 9 additions & 5 deletions freezegun/_async.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import functools
from typing import Any, Callable, TypeVar, cast
from typing import Awaitable, Any, Callable, TypeVar, Coroutine
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing_extensions import ParamSpec

_CallableT = TypeVar("_CallableT", bound=Callable[..., Any])
P = ParamSpec("P")
T = TypeVar("T")


def wrap_coroutine(api: Any, coroutine: _CallableT) -> _CallableT:
def wrap_coroutine(api: Any, coroutine: "Callable[P, Awaitable[T]]") -> "Callable[P, Coroutine[Any, Any, T]]":
@functools.wraps(coroutine)
async def wrapper(*args: Any, **kwargs: Any) -> Any:
async def wrapper(*args: "P.args", **kwargs: "P.kwargs") -> T:
with api as time_factory:
if api.as_arg:
result = await coroutine(time_factory, *args, **kwargs)
else:
result = await coroutine(*args, **kwargs)
return result

return cast(_CallableT, wrapper)
return wrapper
Loading

0 comments on commit b99c901

Please sign in to comment.