Last active
December 10, 2020 11:57
-
-
Save pawelrubin/a394702e4029809f30515621fc41ab1f to your computer and use it in GitHub Desktop.
Protocol for annotating comparable types.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from abc import abstractmethod | |
from typing import TypeVar, Protocol | |
class Comparable(Protocol): | |
"""Protocol for annotating comparable types.""" | |
@abstractmethod | |
def __lt__(self: CT, other: CT) -> bool: | |
pass | |
CT = TypeVar("CT", bound=Comparable) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment