Skip to content

Restore class-decorator overload annotation for freeze_time #574

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

Merged

Conversation

sfreilich
Copy link
Contributor

This was removed in f9235ae, apparently inadvertently.

@sfreilich
Copy link
Contributor Author

Is this just about avoiding a warning on MyPy for Python 3.13? The problem is, this breaks Pytype, it no longer knows that the decorated class has the same type.

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).
@sfreilich sfreilich force-pushed the restore-class-decorator-overload branch from e1c6c98 to 1df6623 Compare June 4, 2025 19:55
@sfreilich
Copy link
Contributor Author

I think the right thing to do is to put that back and suppress the warning in mypy (which I believe still gets the inference correct on both class and method decorators, even with the extra annotation). I've updated the change to do that.

Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @sfreilich - this does make sense. Thanks for adding an explanation as well, that should avoid us from making the same mistake again 🙂

@bblommers bblommers merged commit 5dff43d into spulec:master Jun 7, 2025
15 checks passed
@sfreilich sfreilich deleted the restore-class-decorator-overload branch June 7, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants