@@ -155,13 +155,12 @@ class DoctypeTransformer(lark.visitors.Transformer):
155
155
[('tuple', 0, 5), ('int', 9, 12)]
156
156
"""
157
157
158
- def __init__ (self , * , inspector = None , replace_doctypes = None , ** kwargs ):
158
+ def __init__ (self , * , types_db = None , replace_doctypes = None , ** kwargs ):
159
159
"""
160
160
Parameters
161
161
----------
162
- inspector : ~.StaticInspector
163
- A dictionary mapping atomic names used in doctypes to information such
164
- as where to import from or how to replace the name itself.
162
+ types_db : ~.TypesDatabase
163
+ A static database of collected types usable as an annotation.
165
164
replace_doctypes : dict[str, str], optional
166
165
Replacements for human-friendly aliases.
167
166
kwargs : dict[Any, Any], optional
@@ -170,7 +169,7 @@ def __init__(self, *, inspector=None, replace_doctypes=None, **kwargs):
170
169
if replace_doctypes is None :
171
170
replace_doctypes = {}
172
171
173
- self .inspector = inspector
172
+ self .types_db = types_db
174
173
self .replace_doctypes = replace_doctypes
175
174
176
175
self ._collected_imports = None
@@ -302,16 +301,16 @@ def contains(self, tree):
302
301
def literals (self , tree ):
303
302
out = ", " .join (tree .children )
304
303
out = f"Literal[{ out } ]"
305
- if self .inspector is not None :
306
- _ , known_import = self .inspector .query ("Literal" )
304
+ if self .types_db is not None :
305
+ _ , known_import = self .types_db .query ("Literal" )
307
306
if known_import :
308
307
self ._collected_imports .add (known_import )
309
308
return out
310
309
311
310
def _find_import (self , qualname , meta ):
312
311
"""Match type names to known imports."""
313
- if self .inspector is not None :
314
- annotation_name , known_import = self .inspector .query (qualname )
312
+ if self .types_db is not None :
313
+ annotation_name , known_import = self .types_db .query (qualname )
315
314
else :
316
315
annotation_name = None
317
316
known_import = None
0 commit comments