10000 Get rid of the .messages() method · python/mypy@caa8477 · GitHub
[go: up one dir, main page]

Skip to content

Commit caa8477

Browse files
committed
Get rid of the .messages() method
1 parent 376982d commit caa8477

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

mypy/errors.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -407,16 +407,6 @@ def new_messages(self) -> List[str]:
407407
msgs.extend(self.file_messages(path))
408408
return msgs
409409

410-
def messages(self) -> List[str]:
411-
"""Return a string list that represents the error messages.
412-
413-
Use a form suitable for displaying to the user.
414-
"""
415-
msgs = []
416-
for path in self.error_info_map.keys():
417-
msgs.extend(self.file_messages(path))
418-
return msgs
419-
420410
def targets(self) -> Set[str]:
421411
"""Return a set of all targets that contain errors."""
422412
# TODO: Make sure that either target is always defined or that not being defined
@@ -603,7 +593,8 @@ def report_internal_error(err: Exception, file: Optional[str], line: int,
603593
# Dump out errors so far, they often provide a clue.
604594
# But catch unexpected errors rendering them.
605595
try:
606-
for msg in errors.messages():
596+
errors.flushed_files = set() # Print out already flushed messages too
597+
for msg in errors.new_messages():
607598
print(msg)
608599
except Exception as e:
609600
print("Failed to dump errors:", repr(e), file=sys.stderr)

mypy/server/update.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ def update_single(self, module: str, path: str) -> Tuple[List[str],
195195
result = update_single_isolated(module, path, manager, previous_modules)
196196
if isinstance(result, BlockedUpdate):
197197
# Blocking error -- just give up
198-
module, path, remaining = result
198+
module, path, remaining, errors = result
199199
self.previous_modules = get_module_to_path_map(manager)
200-
return manager.errors.messages(), remaining, (module, path), True
200+
return errors, remaining, (module, path), True
201201
assert isinstance(result, NormalUpdate) # Work around #4124
202202
module, path, remaining, tree, graph = result
203203

@@ -230,7 +230,7 @@ def update_single(self, module: str, path: str) -> Tuple[List[str],
230230
self.previous_modules = get_module_to_path_map(manager)
231231
self.type_maps = extract_type_maps(graph)
232232

233-
return manager.errors.messages(), remaining, (module, path), False
233+
return manager.errors.new_messages(), remaining, (module, path), False
234234

235235

236236
def mark_all_meta_as_memory_only(graph: Dict[str, State],
@@ -271,7 +271,8 @@ def get_all_dependencies(manager: BuildManager, graph: Dict[str, State],
271271
# are similar to NormalUpdate (but there are fewer).
272272
BlockedUpdate = NamedTuple('BlockedUpdate', [('module', str),
273273
('path', str),
274-
('remaining', List[Tuple[str, str]])])
274+
('remaining', List[Tuple[str, str]]),
275+
('messages', List[str])])
275276

276277
UpdateResult = Union[NormalUpdate, BlockedUpdate]
277278

@@ -318,7 +319,7 @@ def update_single_isolated(module: str,
318319
remaining_modules = [(module, path)]
319320
else:
320321
remaining_modules = []
321-
return BlockedUpdate(err.module_with_blocker, path, remaining_modules)
322+
return BlockedUpdate(err.module_with_blocker, path, remaining_modules, err.messages)
322323

323324
if not os.path.isfile(path):
324325
graph = delete_module(module, graph, manager)
@@ -353,7 +354,7 @@ def update_single_isolated(module: str,
353354
manager.modules.clear()
354355
manager.modules.update(old_modules)
355356
del graph[module]
356-
return BlockedUpdate(module, path, remaining_modules)
357+
return BlockedUpdate(module, path, remaining_modules, err.messages)
357358
state.semantic_analysis_pass_three()
358359
state.semantic_analysis_apply_patches()
359360

0 commit comments

Comments
 (0)
0