Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ParamSpec in freezegun stubs #7053

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions stubs/freezegun/freezegun/api.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ from collections.abc import Awaitable, Callable, Iterator, Sequence
from datetime import date, datetime, timedelta
from numbers import Real
from typing import Any, TypeVar, Union, overload
from typing_extensions import ParamSpec

_T = TypeVar("_T")
_P = ParamSpec("_P")
_Freezable = Union[str, datetime, date, timedelta]

class TickingDateTimeFactory:
Expand Down Expand Up @@ -37,16 +39,16 @@ class _freeze_time:
@overload
def __call__(self, func: type[_T]) -> type[_T]: ...
@overload
def __call__(self, func: Callable[..., Awaitable[_T]]) -> Callable[..., Awaitable[_T]]: ...
def __call__(self, func: Callable[_P, Awaitable[_T]]) -> Callable[_P, Awaitable[_T]]: ...
@overload
def __call__(self, func: Callable[..., _T]) -> Callable[..., _T]: ...
def __call__(self, func: Callable[_P, _T]) -> Callable[_P, _T]: ...
def __enter__(self) -> FrozenDateTimeFactory | StepTickTimeFactory: ...
def __exit__(self, *args: Any) -> None: ...
def start(self) -> Any: ...
def stop(self) -> None: ...
def decorate_class(self, klass: type[_T]) -> _T: ...
def decorate_coroutine(self, coroutine: _T) -> _T: ...
def decorate_callable(self, func: Callable[..., _T]) -> Callable[..., _T]: ...
def decorate_callable(self, func: Callable[_P, _T]) -> Callable[_P, _T]: ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't correct: if as_arg or as_kwarg is given, it injects an additional arg/kwarg. https://github.com/spulec/freezegun/blob/8994558274161b527ab83a3b13ea5969e9ebd144/freezegun/api.py#L783

This also applies to the __call__ overload for functions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Best to leave it until we have Concatenate support, then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not enough for the kwarg.


def freeze_time(
time_to_freeze: _Freezable | Callable[..., _Freezable] | Iterator[_Freezable] | None = ...,
Expand Down