File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -860,12 +860,17 @@ class Base:
860
860
pass
861
861
def foo() -> int:
862
862
import y
863
+ reveal_type(y.Sub.attr)
863
864
return y.Sub.attr
864
865
[file y.py]
865
866
import x
866
867
class Sub(x.Base):
867
868
attr = 0
868
869
[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'
869
874
870
875
-- This case has a symmetrical cycle, so it doesn't matter in what
871
876
-- order the files are processed. It depends on the lightweight type
@@ -927,3 +932,30 @@ class Sub(x.Base):
927
932
sattr = ''
928
933
uattr = u''
929
934
[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'
You can’t perform that action at this time.
0 commit comments