Skip to content

Commit 29bd0c2

Browse files
committed
Do not depend on literal inference in test
1 parent 5120c4e commit 29bd0c2

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

test-data/unit/check-unreachable-code.test

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -481,20 +481,20 @@ import typing
481481
def make() -> bool: pass
482482
PY2 = PY3 = make()
483483

484-
a = PY2 and 's'
485-
b = PY3 and 's'
486-
c = PY2 or 's'
487-
d = PY3 or 's'
488-
e = (PY2 or PY3) and 's'
489-
f = (PY3 or PY2) and 's'
490-
g = (PY2 or PY3) or 's'
491-
h = (PY3 or PY2) or 's'
484+
a = PY2 and str()
485+
b = PY3 and str()
486+
c = PY2 or str()
487+
d = PY3 or str()
488+
e = (PY2 or PY3) and str()
489+
f = (PY3 or PY2) and str()
490+
g = (PY2 or PY3) or str()
491+
h = (PY3 or PY2) or str()
492492
reveal_type(a) # N: Revealed type is "builtins.bool"
493-
reveal_type(b) # N: Revealed type is "Literal['s']"
494-
reveal_type(c) # N: Revealed type is "Literal['s']"
493+
reveal_type(b) # N: Revealed type is "builtins.str"
494+
reveal_type(c) # N: Revealed type is "builtins.str"
495495
reveal_type(d) # N: Revealed type is "builtins.bool"
496-
reveal_type(e) # N: Revealed type is "Literal['s']"
497-
reveal_type(f) # N: Revealed type is "Literal['s']"
496+
reveal_type(e) # N: Revealed type is "builtins.str"
497+
reveal_type(f) # N: Revealed type is "builtins.str"
498498
reveal_type(g) # N: Revealed type is "builtins.bool"
499499
reveal_type(h) # N: Revealed type is "builtins.bool"
500500
[builtins fixtures/ops.pyi]
@@ -504,20 +504,20 @@ reveal_type(h) # N: Revealed type is "builtins.bool"
504504
# flags: --platform linux
505505
import sys
506506

507-
t_and_t = (sys.platform == 'linux' and sys.platform == 'linux') and 's'
508-
t_or_t = (sys.platform == 'linux' or sys.platform == 'linux') and 's'
509-
t_and_f = (sys.platform == 'linux' and sys.platform == 'windows') and 's'
510-
t_or_f = (sys.platform == 'linux' or sys.platform == 'windows') and 's'
511-
f_and_t = (sys.platform == 'windows' and sys.platform == 'linux') and 's'
512-
f_or_t = (sys.platform == 'windows' or sys.platform == 'linux') and 's'
513-
f_and_f = (sys.platform == 'windows' and sys.platform == 'windows') and 's'
514-
f_or_f = (sys.platform == 'windows' or sys.platform == 'windows') and 's'
515-
reveal_type(t_and_t) # N: Revealed type is "Literal['s']"
516-
reveal_type(t_or_t) # N: Revealed type is "Literal['s']"
507+
t_and_t = (sys.platform == 'linux' and sys.platform == 'linux') and str()
508+
t_or_t = (sys.platform == 'linux' or sys.platform == 'linux') and str()
509+
t_and_f = (sys.platform == 'linux' and sys.platform == 'windows') and str()
510+
t_or_f = (sys.platform == 'linux' or sys.platform == 'windows') and str()
511+
f_and_t = (sys.platform == 'windows' and sys.platform == 'linux') and str()
512+
f_or_t = (sys.platform == 'windows' or sys.platform == 'linux') and str()
513+
f_and_f = (sys.platform == 'windows' and sys.platform == 'windows') and str()
514+
f_or_f = (sys.platform == 'windows' or sys.platform == 'windows') and str()
515+
reveal_type(t_and_t) # N: Revealed type is "builtins.str"
516+
reveal_type(t_or_t) # N: Revealed type is "builtins.str"
517517
reveal_type(f_and_t) # N: Revealed type is "builtins.bool"
518-
reveal_type(f_or_t) # N: Revealed type is "Literal['s']"
518+
reveal_type(f_or_t) # N: Revealed type is "builtins.str"
519519
reveal_type(t_and_f) # N: Revealed type is "builtins.bool"
520-
reveal_type(t_or_f) # N: Revealed type is "Literal['s']"
520+
reveal_type(t_or_f) # N: Revealed type is "builtins.str"
521521
reveal_type(f_and_f) # N: Revealed type is "builtins.bool"
522522
reveal_type(f_or_f) # N: Revealed type is "builtins.bool"
523523
[builtins fixtures/ops.pyi]
@@ -526,26 +526,26 @@ reveal_type(f_or_f) # N: Revealed type is "builtins.bool"
526526
# flags: --platform linux
527527
import sys
528528

529-
not_t = not sys.platform == 'linux' and 's'
530-
not_f = not sys.platform == 'windows' and 's'
531-
not_and_t = not (sys.platform == 'linux' and sys.platform == 'linux') and 's'
532-
not_and_f = not (sys.platform == 'linux' and sys.platform == 'windows') and 's'
533-
not_or_t = not (sys.platform == 'linux' or sys.platform == 'linux') and 's'
534-
not_or_f = not (sys.platform == 'windows' or sys.platform == 'windows') and 's'
529+
not_t = not sys.platform == 'linux' and str()
530+
not_f = not sys.platform == 'windows' and str()
531+
not_and_t = not (sys.platform == 'linux' and sys.platform == 'linux') and str()
532+
not_and_f = not (sys.platform == 'linux' and sys.platform == 'windows') and str()
533+
not_or_t = not (sys.platform == 'linux' or sys.platform == 'linux') and str()
534+
not_or_f = not (sys.platform == 'windows' or sys.platform == 'windows') and str()
535535
reveal_type(not_t) # N: Revealed type is "builtins.bool"
536-
reveal_type(not_f) # N: Revealed type is "Literal['s']"
536+
reveal_type(not_f) # N: Revealed type is "builtins.str"
537537
reveal_type(not_and_t) # N: Revealed type is "builtins.bool"
538-
reveal_type(not_and_f) # N: Revealed type is "Literal['s']"
538+
reveal_type(not_and_f) # N: Revealed type is "builtins.str"
539539
reveal_type(not_or_t) # N: Revealed type is "builtins.bool"
540-
reveal_type(not_or_f) # N: Revealed type is "Literal['s']"
540+
reveal_type(not_or_f) # N: Revealed type is "builtins.str"
541541
[builtins fixtures/ops.pyi]
542542

543543
[case testConditionalValuesUnsupportedOps]
544544
# flags: --platform linux
545545
import sys
546546

547-
unary_minus = -(sys.platform == 'linux') and 's'
548-
binary_minus = ((sys.platform == 'linux') - (sys.platform == 'linux')) and 's'
547+
unary_minus = -(sys.platform == 'linux') and str()
548+
binary_minus = ((sys.platform == 'linux') - (sys.platform == 'linux')) and str()
549549
reveal_type(unary_minus) # N: Revealed type is "Union[Literal[0], builtins.str]"
550550
reveal_type(binary_minus) # N: Revealed type is "Union[Literal[0], builtins.str]"
551551
[builtins fixtures/ops.pyi]

test-data/unit/fixtures/ops.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class tuple(Sequence[Tco]):
2525
class function: pass
2626

2727
class str:
28-
def __init__(self, x: 'int') -> None: pass
28+
def __init__(self, x: 'int' = ...) -> None: pass
2929
def __add__(self, x: 'str') -> 'str': pass
3030
def __eq__(self, x: object) -> bool: pass
3131
def startswith(self, x: 'str') -> bool: pass

0 commit comments

Comments
 (0)