File tree Expand file tree Collapse file tree 2 files changed +24
-26
lines changed Expand file tree Collapse file tree 2 files changed +24
-26
lines changed Original file line number Diff line number Diff 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]"
506483reveal_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]
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments