Skip to content

@total_ordering with __lt__ defined in base class reports false positive missing-attribute] #4379

Description

@jorenham

Describe the Bug

from functools import total_ordering

class Base:
    def __lt__(self, rhs: int, /) -> bool: ...

@total_ordering  # ❌ Class `Child` must define at least one of the rich comparison methods. [missing-attribute]
class Child: ...

I encountered this in the wild while writing stubs for numba.np.types.NPTimedelta (src).

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEYArugMYAuuuUcdENxuSmzoc2qKAH1BmGJQjoA5gB10KllFRweAIU0xEKukboywdCRKhsLACjgwoYADR1KACziJe6Ni4D0AJR0ALQAfHR4XF6EMSoqAAKi4lKUMnKKahpadADCbtCY0bHoIE4gZJQwYFCkhBw0UBQgAL5lqOwQAG4wAGLQMBRoWHhEZC1AA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions