Skip to content

Commit 1df6623

Browse files
committed
Restore class-decorator overload annotation for freeze_time
This was removed in f9235ae without explanation, possibly because mypy objects to the overlap under Python 3.13. But Pytype needs that to infer that the type is unchanged when a class is decorated with `@freezegun.freeze_time` (unlike mypy, which assumes class decorators, unlike function decorators, always leave the type unchanged).
1 parent ba06fa4 commit 1df6623

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

freezegun/api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,13 @@ def __init__(
632632
self.as_kwarg = as_kwarg
633633
self.real_asyncio = real_asyncio
634634

635+
# mypy objects to this because Type is Callable, but Pytype needs it because
636+
# (unlike mypy's) its inference does not assume class decorators always leave
637+
# the type unchanged.
638+
@overload
639+
def __call__(self, func: Type[T2]) -> Type[T2]: # type: ignore[overload-overlap]
640+
...
641+
635642
@overload
636643
def __call__(self, func: "Callable[P, Awaitable[Any]]") -> "Callable[P, Awaitable[Any]]":
637644
...

0 commit comments

Comments
 (0)