@@ -143,6 +143,10 @@ def __init__(self, manager: BuildManager, graph: Graph) -> None:
143143 self .errors : list [str ] = [] # Filled in by build if desired
144144
145145
146+ def build_error (msg : str ) -> NoReturn :
147+ raise CompileError ([f"mypy: error: { msg } " ])
148+
149+
146150def build (
147151 sources : list [BuildSource ],
148152 options : Options ,
@@ -241,6 +245,9 @@ def _build(
241245 errors = Errors (options , read_source = lambda path : read_py_file (path , cached_read ))
242246 plugin , snapshot = load_plugins (options , errors , stdout , extra_plugins )
243247
248+ # Validate error codes after plugins are loaded.
249+ options .process_error_codes (error_callback = build_error )
250+
244251 # Add catch-all .gitignore to cache dir if we created it
245252 cache_dir_existed = os .path .isdir (options .cache_dir )
246253
@@ -1546,7 +1553,7 @@ def write_cache(
15461553 source_hash : str ,
15471554 ignore_all : bool ,
15481555 manager : BuildManager ,
1549- ) -> tuple [str , tuple [dict [str , Any ], str , str ] | None ]:
1556+ ) -> tuple [str , tuple [dict [str , Any ], str ] | None ]:
15501557 """Write cache files for a module.
15511558
15521559 Note that this mypy's behavior is still correct when any given
@@ -1568,7 +1575,7 @@ def write_cache(
15681575
15691576 Returns:
15701577 A tuple containing the interface hash and inner tuple with cache meta JSON
1571- that should be written and paths to cache files (inner tuple may be None,
1578+ that should be written and path to cache file (inner tuple may be None,
15721579 if the cache data could not be written).
15731580 """
15741581 metastore = manager .metastore
@@ -1662,12 +1669,10 @@ def write_cache(
16621669 "ignore_all" : ignore_all ,
16631670 "plugin_data" : plugin_data ,
16641671 }
1665- return interface_hash , (meta , meta_json , data_json )
1672+ return interface_hash , (meta , meta_json )
16661673
16671674
1668- def write_cache_meta (
1669- meta : dict [str , Any ], manager : BuildManager , meta_json : str , data_json : str
1670- ) -> CacheMeta :
1675+ def write_cache_meta (meta : dict [str , Any ], manager : BuildManager , meta_json : str ) -> None :
16711676 # Write meta cache file
16721677 metastore = manager .metastore
16731678 meta_str = json_dumps (meta , manager .options .debug_cache )
@@ -1677,8 +1682,6 @@ def write_cache_meta(
16771682 # The next run will simply find the cache entry out of date.
16781683 manager .log (f"Error writing meta JSON file { meta_json } " )
16791684
1680- return cache_meta_from_dict (meta , data_json )
1681-
16821685
16831686"""Dependency manager.
16841687
@@ -1864,9 +1867,6 @@ class State:
18641867 # List of (path, line number) tuples giving context for import
18651868 import_context : list [tuple [str , int ]]
18661869
1867- # The State from which this module was imported, if any
1868- caller_state : State | None = None
1869-
18701870 # If caller_state is set, the line number in the caller where the import occurred
18711871 caller_line = 0
18721872
@@ -1917,7 +1917,6 @@ def __init__(
19171917 self .manager = manager
19181918 State .order_counter += 1
19191919 self .order = State .order_counter
1920- self .caller_state = caller_state
19211920 self .caller_line = caller_line
19221921 if caller_state :
19231922 self .import_context = caller_state .import_context .copy ()
@@ -2008,11 +2007,6 @@ def __init__(
20082007 self .parse_file (temporary = temporary )
20092008 self .compute_dependencies ()
20102009
2011- @property
2012- def xmeta (self ) -> CacheMeta :
2013- assert self .meta , "missing meta on allegedly fresh module"
2014- return self .meta
2015-
20162010 def add_ancestors (self ) -> None :
20172011 if self .path is not None :
20182012 _ , name = os .path .split (self .path )
@@ -2479,7 +2473,7 @@ def valid_references(self) -> set[str]:
24792473
24802474 return valid_refs
24812475
2482- def write_cache (self ) -> tuple [dict [str , Any ], str , str ] | None :
2476+ def write_cache (self ) -> tuple [dict [str , Any ], str ] | None :
24832477 assert self .tree is not None , "Internal error: method must be called on parsed file only"
24842478 # We don't support writing cache files in fine-grained incremental mode.
24852479 if (
@@ -3477,14 +3471,13 @@ def process_stale_scc(graph: Graph, scc: list[str], manager: BuildManager) -> No
34773471 for id in stale :
34783472 meta_tuple = meta_tuples [id ]
34793473 if meta_tuple is None :
3480- graph [id ].meta = None
34813474 continue
3482- meta , meta_json , data_json = meta_tuple
3475+ meta , meta_json = meta_tuple
34833476 meta ["dep_hashes" ] = {
34843477 dep : graph [dep ].interface_hash for dep in graph [id ].dependencies if dep in graph
34853478 }
34863479 meta ["error_lines" ] = errors_by_id .get (id , [])
3487- graph [ id ]. meta = write_cache_meta (meta , manager , meta_json , data_json )
3480+ write_cache_meta (meta , manager , meta_json )
34883481
34893482
34903483def sorted_components (
0 commit comments