Skip to content

Commit

Permalink
Test cases with Literal return type for __bool__
Browse files Browse the repository at this point in the history
  • Loading branch information
blablatdinov committed Aug 16, 2023
1 parent bc684ea commit 4ef2523
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test-data/unit/check-protocols.test
Original file line number Diff line number Diff line change
Expand Up @@ -2893,8 +2893,18 @@ ss(None)
class SupportsBool(Protocol):
def __bool__(self) -> bool: ...

class SupportsBoolLiteralTrue(Protocol):
def __bool__(self) -> Literal[True]: ...

class SupportsBoolLiteralFalse(Protocol):
def __bool__(self) -> Literal[True]: ...

def sb(s: SupportsBool) -> None: pass
sb(None)
def sblt(s: SupportsBoolLiteralTrue) -> None: pass
sblt(None)
def sblf(s: SupportsBoolLiteralFalse) -> None: pass
sblf(None)

class HashableStr(Protocol):
def __str__(self) -> str: ...
Expand Down

0 comments on commit 4ef2523

Please sign in to comment.