Skip to content
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

@total_ordering support #4610

Closed
srittau opened this issue Feb 21, 2018 · 5 comments · Fixed by #7831
Closed

@total_ordering support #4610

srittau opened this issue Feb 21, 2018 · 5 comments · Fixed by #7831
Labels

Comments

@srittau
Copy link
Contributor

srittau commented Feb 21, 2018

Please consider the following code:

from functools import total_ordering
from typing import Any


@total_ordering
class Ord:

    def __eq__(self, other: Any) -> bool:
        return False

    def __lt__(self, other: "Ord") -> bool:
        return False


Ord() <= Ord()

mypy 0.560 (using Python 3.6.4, default flags) complains:

test.py:15: error: Unsupported left operand type for <= ("Ord")

It would be helpful if mypy would support @total_ordering.

@gvanrossum
Copy link
Member

Perhaps the implementation of this could be a plugin. There are likely ideas to copy from the attrs plugin that David Euresti recently contributed (though that one has a wider scope).

@chadrik
Copy link
Contributor

chadrik commented Oct 8, 2019

+1. Just got hit by this one.

@gvanrossum
Copy link
Member

Maybe someone can submit a PR.

@aldanor
Copy link

aldanor commented Nov 20, 2020

Can the implementation like pantsbuild/pants#9525 be utilized in base mypy?

@JelleZijlstra
Copy link
Member

@aldanor that seems reasonable, since this is a standard library function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants