MCPcopy
hub / github.com/python/mypy / run_build

Function run_build

mypy/main.py:211–254  ·  view source on GitHub ↗
(
    sources: list[BuildSource],
    options: Options,
    fscache: FileSystemCache,
    t0: float,
    stdout: TextIO,
    stderr: TextIO,
)

Source from the content-addressed store, hash-verified

209
210
211def run_build(
212 sources: list[BuildSource],
213 options: Options,
214 fscache: FileSystemCache,
215 t0: float,
216 stdout: TextIO,
217 stderr: TextIO,
218) -> tuple[BuildResultThunk | None, list[str], bool]:
219 formatter = util.FancyFormatter(
220 stdout, stderr, options.hide_error_codes, hide_success=bool(options.output)
221 )
222
223 messages = []
224 messages_by_file = defaultdict(list)
225
226 def flush_errors(filename: str | None, new_messages: list[str], serious: bool) -> None:
227 if options.pretty:
228 new_messages = formatter.fit_in_terminal(new_messages)
229 messages.extend(new_messages)
230 if new_messages:
231 messages_by_file[filename].extend(new_messages)
232 if options.non_interactive:
233 # Collect messages and possibly show them later.
234 return
235 f = stderr if serious else stdout
236 show_messages(new_messages, f, formatter, options)
237
238 serious = False
239 blockers = False
240 res = None
241 try:
242 # Keep a dummy reference (res) for memory profiling afterwards, as otherwise
243 # the result could be freed.
244 res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
245 except CompileError as e:
246 blockers = True
247 if not e.use_stdout:
248 serious = True
249
250 if res:
251 res.manager.metastore.close()
252
253 maybe_write_junit_xml(time.time() - t0, serious, messages, messages_by_file, options)
254 return BuildResultThunk(res), messages, blockers
255
256
257def show_messages(

Callers 1

mainFunction · 0.85

Calls 5

boolClass · 0.85
maybe_write_junit_xmlFunction · 0.85
BuildResultThunkClass · 0.85
buildMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…