-
Notifications
You must be signed in to change notification settings - Fork 105
Implement a basic model for functools.total_ordering
#537
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
Conversation
For this, instead of using a boolean flag in the class metadata you can have a Then you can emit the error according to that range. |
We could probably add a merge method to ClassSynthesizedFields and calculate + merge total_ordering separately from the other stuff.
|
fecea6a
to
76f3b0d
Compare
Is there a way to get a text range of the decorator in |
functools.total_ordering
functools.total_ordering
7f1fa96
to
aeaba40
Compare
BindingClassMetadata doesn't give this information, but we could change its decorator representation from
pyrefly/pyrefly/lib/binding/class.rs Line 118 in 231ac8d
|
Thanks so much for the code pointers, @yangdanny97! Really appreciate your help! |
@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thanks! We'll get this merged soon.
@yangdanny97 merged this pull request in d415773. |
This PR adds modelling of
functools.total_ordering
(closes #491), which allows a class with (at least) one rich comparison method to automatically have all other rich comparison methods.At a high level, this PR incorporates the following changes:
is_total_ordering
in class metadata if the decorator is present.I have some open issues that can be fixed either in this PR after receiving some code pointers, or in subsequent PRs.
Open issues (marked in FIXMEs):
__lt__
is synthesized from__gt__
, then they should have the same type. Currently we model the synthesizing order, but we are not giving the same type.@dataclass
and@total_ordering
at the same time, and they should have synthesized methods from both decorators.