Skip to content

Commit be5a747

Browse files
authored
Remove references to quick_and_dirty in fixup.py (python#6543)
--quick is long dead but the machinery was reused for initial daemon cache loads. Update names and comments accordingly.
1 parent 63339e7 commit be5a747

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

mypy/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,8 +1794,8 @@ def load_tree(self, temporary: bool = False) -> None:
17941794

17951795
def fix_cross_refs(self) -> None:
17961796
assert self.tree is not None, "Internal error: method must be called on parsed file only"
1797-
# We need to set quick_and_dirty when doing a fine grained
1798-
# cache load because we need to gracefully handle missing modules.
1797+
# We need to set allow_missing when doing a fine grained cache
1798+
# load because we need to gracefully handle missing modules.
17991799
fixup_module(self.tree, self.manager.modules,
18001800
self.options.use_fine_grained_cache)
18011801

mypy/fixup.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616
from mypy.lookup import lookup_fully_qualified
1717

1818

19-
# N.B: we do a quick_and_dirty fixup in both quick_and_dirty mode and
20-
# when fixing up a fine-grained incremental cache load (since there may
21-
# be cross-refs into deleted modules)
19+
# N.B: we do a allow_missing fixup when fixing up a fine-grained
20+
# incremental cache load (since there may be cross-refs into deleted
21+
# modules)
2222
def fixup_module(tree: MypyFile, modules: Dict[str, MypyFile],
23-
quick_and_dirty: bool) -> None:
24-
node_fixer = NodeFixer(modules, quick_and_dirty)
23+
allow_missing: bool) -> None:
24+
node_fixer = NodeFixer(modules, allow_missing)
2525
node_fixer.visit_symbol_table(tree.names)
2626

2727

2828
# TODO: Fix up .info when deserializing, i.e. much earlier.
2929
class NodeFixer(NodeVisitor[None]):
3030
current_info = None # type: Optional[TypeInfo]
3131

32-
def __init__(self, modules: Dict[str, MypyFile], quick_and_dirty: bool) -> None:
32+
def __init__(self, modules: Dict[str, MypyFile], allow_missing: bool) -> None:
3333
self.modules = modules
34-
self.quick_and_dirty = quick_and_dirty
35-
self.type_fixer = TypeFixer(self.modules, quick_and_dirty)
34+
self.allow_missing = allow_missing
35+
self.type_fixer = TypeFixer(self.modules, allow_missing)
3636

3737
# NOTE: This method isn't (yet) part of the NodeVisitor API.
3838
def visit_type_info(self, info: TypeInfo) -> None:
@@ -57,7 +57,7 @@ def visit_type_info(self, info: TypeInfo) -> None:
5757
if info.metaclass_type:
5858
info.metaclass_type.accept(self.type_fixer)
5959
if info._mro_refs:
60-
info.mro = [lookup_qualified_typeinfo(self.modules, name, self.quick_and_dirty)
60+
info.mro = [lookup_qualified_typeinfo(self.modules, name, self.allow_missing)
6161
for name in info._mro_refs]
6262
info._mro_refs = None
6363
finally:
@@ -74,14 +74,14 @@ def visit_symbol_table(self, symtab: SymbolTable) -> None:
7474
value.node = self.modules[cross_ref]
7575
else:
7676
stnode = lookup_qualified_stnode(self.modules, cross_ref,
77-
self.quick_and_dirty)
77+
self.allow_missing)
7878
if stnode is not None:
7979
value.node = stnode.node
80-
elif not self.quick_and_dirty:
80+
elif not self.allow_missing:
8181
assert stnode is not None, "Could not find cross-ref %s" % (cross_ref,)
8282
else:
83-
# We have a missing crossref in quick mode, need to put something
84-
value.node = stale_info(self.modules)
83+
# We have a missing crossref in allow missing mode, need to put something
84+
value.node = missing_info(self.modules)
8585
else:
8686
if isinstance(value.node, TypeInfo):
8787
# TypeInfo has no accept(). TODO: Add it?
@@ -137,17 +137,17 @@ def visit_type_alias(self, a: TypeAlias) -> None:
137137

138138

139139
class TypeFixer(TypeVisitor[None]):
140-
def __init__(self, modules: Dict[str, MypyFile], quick_and_dirty: bool) -> None:
140+
def __init__(self, modules: Dict[str, MypyFile], allow_missing: bool) -> None:
141141
self.modules = modules
142-
self.quick_and_dirty = quick_and_dirty
142+
self.allow_missing = allow_missing
143143

144144
def visit_instance(self, inst: Instance) -> None:
145145
# TODO: Combine Instances that are exactly the same?
146146
type_ref = inst.type_ref
147147
if type_ref is None:
148148
return # We've already been here.
149149
inst.type_ref = None
150-
inst.type = lookup_qualified_typeinfo(self.modules, type_ref, self.quick_and_dirty)
150+
inst.type = lookup_qualified_typeinfo(self.modules, type_ref, self.allow_missing)
151151
# TODO: Is this needed or redundant?
152152
# Also fix up the bases, just in case.
153153
for base in inst.type.bases:
@@ -236,39 +236,39 @@ def visit_type_type(self, t: TypeType) -> None:
236236

237237

238238
def lookup_qualified_typeinfo(modules: Dict[str, MypyFile], name: str,
239-
quick_and_dirty: bool) -> TypeInfo:
240-
node = lookup_qualified(modules, name, quick_and_dirty)
239+
allow_missing: bool) -> TypeInfo:
240+
node = lookup_qualified(modules, name, allow_missing)
241241
if isinstance(node, TypeInfo):
242242
return node
243243
else:
244-
# Looks like a missing TypeInfo in quick mode, put something there
245-
assert quick_and_dirty, "Should never get here in normal mode," \
246-
" got {}:{} instead of TypeInfo".format(type(node).__name__,
247-
node.fullname() if node
248-
else '')
249-
return stale_info(modules)
244+
# Looks like a missing TypeInfo during an initial daemon load, put something there
245+
assert allow_missing, "Should never get here in normal mode," \
246+
" got {}:{} instead of TypeInfo".format(type(node).__name__,
247+
node.fullname() if node
248+
else '')
249+
return missing_info(modules)
250250

251251

252252
def lookup_qualified(modules: Dict[str, MypyFile], name: str,
253-
quick_and_dirty: bool) -> Optional[SymbolNode]:
254-
stnode = lookup_qualified_stnode(modules, name, quick_and_dirty)
253+
allow_missing: bool) -> Optional[SymbolNode]:
254+
stnode = lookup_qualified_stnode(modules, name, allow_missing)
255255
if stnode is None:
256256
return None
257257
else:
258258
return stnode.node
259259

260260

261261
def lookup_qualified_stnode(modules: Dict[str, MypyFile], name: str,
262-
quick_and_dirty: bool) -> Optional[SymbolTableNode]:
263-
return lookup_fully_qualified(name, modules, raise_on_missing=not quick_and_dirty)
262+
allow_missing: bool) -> Optional[SymbolTableNode]:
263+
return lookup_fully_qualified(name, modules, raise_on_missing=not allow_missing)
264264

265265

266-
def stale_info(modules: Dict[str, MypyFile]) -> TypeInfo:
267-
suggestion = "<stale cache: consider running mypy without --quick>"
266+
def missing_info(modules: Dict[str, MypyFile]) -> TypeInfo:
267+
suggestion = "<missing info: *should* have gone away during fine-grained update>"
268268
dummy_def = ClassDef(suggestion, Block([]))
269269
dummy_def.fullname = suggestion
270270

271-
info = TypeInfo(SymbolTable(), dummy_def, "<stale>")
271+
info = TypeInfo(SymbolTable(), dummy_def, "<missing>")
272272
obj_type = lookup_qualified(modules, 'builtins.object', False)
273273
assert isinstance(obj_type, TypeInfo)
274274
info.bases = [Instance(obj_type, [])]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy