Skip to content

Commit 5d58439

Browse files
author
Guido van Rossum
committed
More tests.
1 parent 564fbb4 commit 5d58439

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test-data/unit/check-modules.test

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,12 +860,17 @@ class Base:
860860
pass
861861
def foo() -> int:
862862
import y
863+
reveal_type(y.Sub.attr)
863864
return y.Sub.attr
864865
[file y.py]
865866
import x
866867
class Sub(x.Base):
867868
attr = 0
868869
[out]
870+
tmp/y.py:1: note: In module imported here,
871+
main:1: note: ... from here:
872+
tmp/x.py: note: In function "foo":
873+
tmp/x.py:5: error: Revealed type is 'builtins.int'
869874

870875
-- This case has a symmetrical cycle, so it doesn't matter in what
871876
-- order the files are processed. It depends on the lightweight type
@@ -927,3 +932,30 @@ class Sub(x.Base):
927932
sattr = ''
928933
uattr = u''
929934
[out]
935+
936+
-- This case tests module-level variables.
937+
938+
[case testImportCycleStability7]
939+
import x
940+
[file x.py]
941+
def foo() -> int:
942+
import y
943+
reveal_type(y.value)
944+
return y.value
945+
[file y.py]
946+
import x
947+
value = 12
948+
[out]
949+
main:1: note: In module imported here:
950+
tmp/x.py: note: In function "foo":
951+
tmp/x.py:3: error: Revealed type is 'builtins.int'
952+
953+
-- This is not really cycle-related but still about the lightweight
954+
-- type checker.
955+
956+
[case testImportCycleStability8]
957+
x = 1 # type: str
958+
reveal_type(x)
959+
[out]
960+
main:1: error: Incompatible types in assignment (expression has type "int", variable has type "str")
961+
main:2: error: Revealed type is 'builtins.str'

0 commit comments

Comments
 (0)