Skip to content

Commit dad9b05

Browse files
committed
Push what I've got
1 parent ec94017 commit dad9b05

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

test-data/unit/check-classes.test

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -474,36 +474,15 @@ class B(A):
474474
pass
475475

476476
[case testOverride__new__WithLiteralReturnPassing]
477-
[file builtins.py]
478-
from typing import Literal, Protocol, overload
479-
480-
class str: pass
481-
class dict: pass
482-
class float: pass
483-
484-
class _Truthy(Protocol):
485-
def __bool__(self) -> Literal[True]: pass
486-
487-
class _Falsy(Protocol):
488-
def __bool__(self) -> Literal[False]: pass
489-
490-
class bool(int):
491-
@overload
492-
def __new__(cls, __o: _Truthy) -> Literal[True]: pass
493-
@overload
494-
def __new__(cls, __o: _Falsy) -> Literal[False]: pass
495-
def __new__(cls, __o: object):
496-
pass
477+
from typing import Literal
497478

498-
class Falsey:
479+
class Falsy:
499480
def __bool__(self) -> Literal[False]: pass
500481

501-
reveal_type(bool(Falsey())) # N: Revealed type is "Literal[False]"
502-
503-
class int:
504-
def __new__(cls) -> Literal[0]: pass
505-
482+
reveal_type(bool(Falsy())) # N: Revealed type is "Literal[False]"
506483
reveal_type(int()) # N: Revealed type is "Literal[0]"
484+
485+
[builtins fixtures/literal__new__.pyi]
507486
[typing fixtures/typing-medium.pyi]
508487

509488
[case testOverride__new__WithLiteralReturnFailing]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from typing import Literal, Protocol, overload
2+
3+
class str: pass
4+
class dict: pass
5+
class float: pass
6+
class int:
7+
def __new__(cls) -> Literal[0]: pass
8+
9+
class _Truthy(Protocol):
10+
def __bool__(self) -> Literal[True]: pass
11+
12+
class _Falsy(Protocol):
13+
def __bool__(self) -> Literal[False]: pass
14+
15+
class bool(int):
16+
@overload
17+
def __new__(cls, __o: _Truthy) -> Literal[True]: pass
18+
@overload
19+
def __new__(cls, __o: _Falsy) -> Literal[False]: pass

0 commit comments

Comments
 (0)