File tree 2 files changed +45
-2
lines changed
2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -4611,7 +4611,11 @@ def add_symbol_table_node(self,
4611
4611
names = self .current_symbol_table (escape_comprehensions = escape_comprehensions )
4612
4612
existing = names .get (name )
4613
4613
if isinstance (symbol .node , PlaceholderNode ) and can_defer :
4614
- self .defer (context )
4614
+ if context is not None :
4615
+ self .process_placeholder (name , 'name' , context )
4616
+ else :
4617
+ # see note in docstring describing None contexts
4618
+ self .defer ()
4615
4619
if (existing is not None
4616
4620
and context is not None
4617
4621
and not is_valid_replacement (existing , symbol )):
Original file line number Diff line number Diff line change @@ -3131,4 +3131,43 @@ main:2: error: Cannot find implementation or library stub for module named "blea
3131
3131
# flags: --ignore-missing-imports
3132
3132
import bleach.xyz
3133
3133
from bleach.abc import fgh
3134
- [file bleach/__init__.pyi]
3134
+ [file bleach/__init__.pyi]
3135
+
3136
+ [case testCyclicUndefinedImportWithName]
3137
+ import a
3138
+ [file a.py]
3139
+ from b import no_such_export
3140
+ [file b.py]
3141
+ from a import no_such_export # E: Module "a" has no attribute "no_such_export"
3142
+
3143
+ [case testCyclicUndefinedImportWithStar1]
3144
+ import a
3145
+ [file a.py]
3146
+ from b import no_such_export
3147
+ [file b.py]
3148
+ from a import *
3149
+ [out]
3150
+ tmp/b.py:1: error: Cannot resolve name "no_such_export" (possible cyclic definition)
3151
+ tmp/a.py:1: error: Module "b" has no attribute "no_such_export"
3152
+
3153
+ [case testCyclicUndefinedImportWithStar2]
3154
+ import a
3155
+ [file a.py]
3156
+ from b import no_such_export
3157
+ [file b.py]
3158
+ from c import *
3159
+ [file c.py]
3160
+ from a import *
3161
+ [out]
3162
+ tmp/c.py:1: error: Cannot resolve name "no_such_export" (possible cyclic definition)
3163
+ tmp/b.py:1: error: Cannot resolve name "no_such_export" (possible cyclic definition)
3164
+ tmp/a.py:1: error: Module "b" has no attribute "no_such_export"
3165
+
3166
+ [case testCyclicUndefinedImportWithStar3]
3167
+ import test1
3168
+ [file test1.py]
3169
+ from dir1 import *
3170
+ [file dir1/__init__.py]
3171
+ from .test2 import *
3172
+ [file dir1/test2.py]
3173
+ from test1 import aaaa # E: Module "test1" has no attribute "aaaa"
You can’t perform that action at this time.
0 commit comments