You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bcced1e
Browse filesBrowse the repository at this point in the historyBrowse files
Generate dataclass ordering methods only on the decorated class
Summary:
Pyrefly synthesized `__lt__`/`__le__`/`__gt__`/`__ge__` (plus `__eq__`/`__ne__`) on every class carrying ordered dataclass metadata, including plain subclasses that only inherit it. At runtime only the decorated class gets these methods, and subclasses inherit them. This caused two problems:
- Plain subclasses showed signatures typed against themselves (`(self: C, other: C)` rather than `D`'s).
- A user override between the dataclass and a plain subclass was hidden. For example, a `__ge__(self, other: object)` defined on an intermediate class still produced a false `unsupported-operation` error on its subclasses.
The methods are now only synthesized when the class's dataclass metadata is its own (`!is_inherited`). With that, and with `total_ordering` no longer inventing comparison methods (previous diff), a normal member lookup reports the methods a class really uses. So `ordered-dataclass-inheritance` now uses that lookup instead of its own walk over class bodies.
___
landed-with-radar-review
Differential Revision: D126992834
fbshipit-source-id: b870886b6f15041b9a9ab780f61068c017e22b3a
0 commit comments