@@ -100,7 +100,9 @@ def expr_to_unanalyzed_type(
100100 else :
101101 raise TypeTranslationError ()
102102 elif isinstance (expr , IndexExpr ):
103- base = expr_to_unanalyzed_type (expr .base , options , allow_new_syntax , expr )
103+ base = expr_to_unanalyzed_type (
104+ expr .base , options , allow_new_syntax , expr , lookup_qualified = lookup_qualified
105+ )
104106 if isinstance (base , UnboundType ):
105107 if base .args :
106108 raise TypeTranslationError ()
@@ -124,9 +126,18 @@ def expr_to_unanalyzed_type(
124126 # TODO: this is not the optimal solution as we are basically getting rid
125127 # of the Annotation definition and only returning the type information,
126128 # losing all the annotations.
127- return expr_to_unanalyzed_type (args [0 ], options , allow_new_syntax , expr )
129+ return expr_to_unanalyzed_type (
130+ args [0 ], options , allow_new_syntax , expr , lookup_qualified = lookup_qualified
131+ )
128132 base .args = tuple (
129- expr_to_unanalyzed_type (arg , options , allow_new_syntax , expr , allow_unpack = True )
133+ expr_to_unanalyzed_type (
134+ arg ,
135+ options ,
136+ allow_new_syntax ,
137+ expr ,
138+ allow_unpack = True ,
139+ lookup_qualified = lookup_qualified ,
140+ )
130141 for arg in args
131142 )
132143 if not base .args :
@@ -141,8 +152,12 @@ def expr_to_unanalyzed_type(
141152 ):
142153 return UnionType (
143154 [
144- expr_to_unanalyzed_type (expr .left , options , allow_new_syntax ),
145- expr_to_unanalyzed_type (expr .right , options , allow_new_syntax ),
155+ expr_to_unanalyzed_type (
156+ expr .left , options , allow_new_syntax , lookup_qualified = lookup_qualified
157+ ),
158+ expr_to_unanalyzed_type (
159+ expr .right , options , allow_new_syntax , lookup_qualified = lookup_qualified
160+ ),
146161 ],
147162 uses_pep604_syntax = True ,
148163 )
@@ -178,12 +193,16 @@ def expr_to_unanalyzed_type(
178193 if typ is not default_type :
179194 # Two types
180195 raise TypeTranslationError ()
181- typ = expr_to_unanalyzed_type (arg , options , allow_new_syntax , expr )
196+ typ = expr_to_unanalyzed_type (
197+ arg , options , allow_new_syntax , expr , lookup_qualified = lookup_qualified
198+ )
182199 continue
183200 else :
184201 raise TypeTranslationError ()
185202 elif i == 0 :
186- typ = expr_to_unanalyzed_type (arg , options , allow_new_syntax , expr )
203+ typ = expr_to_unanalyzed_type (
204+ arg , options , allow_new_syntax , expr , lookup_qualified = lookup_qualified
205+ )
187206 elif i == 1 :
188207 name = _extract_argument_name (arg )
189208 else :
@@ -192,7 +211,14 @@ def expr_to_unanalyzed_type(
192211 elif isinstance (expr , ListExpr ):
193212 return TypeList (
194213 [
195- expr_to_unanalyzed_type (t , options , allow_new_syntax , expr , allow_unpack = True )
214+ expr_to_unanalyzed_type (
215+ t ,
216+ options ,
217+ allow_new_syntax ,
218+ expr ,
219+ allow_unpack = True ,
220+ lookup_qualified = lookup_qualified ,
221+ )
196222 for t in expr .items
197223 ],
198224 line = expr .line ,
@@ -203,7 +229,9 @@ def expr_to_unanalyzed_type(
203229 elif isinstance (expr , BytesExpr ):
204230 return parse_type_string (expr .value , "builtins.bytes" , expr .line , expr .column )
205231 elif isinstance (expr , UnaryExpr ):
206- typ = expr_to_unanalyzed_type (expr .expr , options , allow_new_syntax )
232+ typ = expr_to_unanalyzed_type (
233+ expr .expr , options , allow_new_syntax , lookup_qualified = lookup_qualified
234+ )
207235 if isinstance (typ , RawExpressionType ):
208236 if isinstance (typ .literal_value , int ):
209237 if expr .op == "-" :
@@ -225,7 +253,10 @@ def expr_to_unanalyzed_type(
225253 return EllipsisType (expr .line )
226254 elif allow_unpack and isinstance (expr , StarExpr ):
227255 return UnpackType (
228- expr_to_unanalyzed_type (expr .expr , options , allow_new_syntax ), from_star_syntax = True
256+ expr_to_unanalyzed_type (
257+ expr .expr , options , allow_new_syntax , lookup_qualified = lookup_qualified
258+ ),
259+ from_star_syntax = True ,
229260 )
230261 elif isinstance (expr , DictExpr ):
231262 if not expr .items :
@@ -236,12 +267,18 @@ def expr_to_unanalyzed_type(
236267 if not isinstance (item_name , StrExpr ):
237268 if item_name is None :
238269 extra_items_from .append (
239- expr_to_unanalyzed_type (value , options , allow_new_syntax , expr )
270+ expr_to_unanalyzed_type (
271+ value ,
272+ options ,
273+ allow_new_syntax ,
274+ expr ,
275+ lookup_qualified = lookup_qualified ,
276+ )
240277 )
241278 continue
242279 raise TypeTranslationError ()
243280 items [item_name .value ] = expr_to_unanalyzed_type (
244- value , options , allow_new_syntax , expr
281+ value , options , allow_new_syntax , expr , lookup_qualified = lookup_qualified
245282 )
246283 result = TypedDictType (
247284 items , set (), set (), Instance (MISSING_FALLBACK , ()), expr .line , expr .column
0 commit comments