Skip to content

Commit 5de7da2

Browse files
authored
Update build.py
1 parent 892ad6e commit 5de7da2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

mypy/build.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ def __init__(self, manager: BuildManager, graph: Graph) -> None:
144144
self.errors: list[str] = [] # Filled in by build if desired
145145

146146

147+
def build_error(msg: str) -> NoReturn:
148+
raise CompileError([f"mypy: error: {msg}"])
149+
150+
147151
def build(
148152
sources: list[BuildSource],
149153
options: Options,
@@ -239,6 +243,9 @@ def _build(
239243
errors = Errors(options, read_source=lambda path: read_py_file(path, cached_read))
240244
plugin, snapshot = load_plugins(options, errors, stdout, extra_plugins)
241245

246+
# Validate error codes after plugins are loaded.
247+
options.process_error_codes(error_callback=build_error)
248+
242249
# Add catch-all .gitignore to cache dir if we created it
243250
cache_dir_existed = os.path.isdir(options.cache_dir)
244251

@@ -504,9 +511,6 @@ def load_plugins(
504511
"""
505512
custom_plugins, snapshot = load_plugins_from_config(options, errors, stdout)
506513

507-
if options._on_plugins_loaded is not None:
508-
options._on_plugins_loaded()
509-
510514
custom_plugins += extra_plugins
511515

512516
default_plugin: Plugin = DefaultPlugin(options)

0 commit comments

Comments
 (0)