@@ -143,6 +143,10 @@ def __init__(self, manager: BuildManager, graph: Graph) -> None:
143
143
self .errors : list [str ] = [] # Filled in by build if desired
144
144
145
145
146
+ def build_error (msg : str ) -> NoReturn :
147
+ raise CompileError ([f"mypy: error: { msg } " ])
148
+
149
+
146
150
def build (
147
151
sources : list [BuildSource ],
148
152
options : Options ,
@@ -241,6 +245,9 @@ def _build(
241
245
errors = Errors (options , read_source = lambda path : read_py_file (path , cached_read ))
242
246
plugin , snapshot = load_plugins (options , errors , stdout , extra_plugins )
243
247
248
+ # Validate error codes after plugins are loaded.
249
+ options .process_error_codes (error_callback = build_error )
250
+
244
251
# Add catch-all .gitignore to cache dir if we created it
245
252
cache_dir_existed = os .path .isdir (options .cache_dir )
246
253
@@ -1546,7 +1553,7 @@ def write_cache(
1546
1553
source_hash : str ,
1547
1554
ignore_all : bool ,
1548
1555
manager : BuildManager ,
1549
- ) -> tuple [str , tuple [dict [str , Any ], str , str ] | None ]:
1556
+ ) -> tuple [str , tuple [dict [str , Any ], str ] | None ]:
1550
1557
"""Write cache files for a module.
1551
1558
1552
1559
Note that this mypy's behavior is still correct when any given
@@ -1568,7 +1575,7 @@ def write_cache(
1568
1575
1569
1576
Returns:
1570
1577
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,
1572
1579
if the cache data could not be written).
1573
1580
"""
1574
1581
metastore = manager .metastore
@@ -1662,12 +1669,10 @@ def write_cache(
1662
1669
"ignore_all" : ignore_all ,
1663
1670
"plugin_data" : plugin_data ,
1664
1671
}
1665
- return interface_hash , (meta , meta_json , data_json )
1672
+ return interface_hash , (meta , meta_json )
1666
1673
1667
1674
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 :
1671
1676
# Write meta cache file
1672
1677
metastore = manager .metastore
1673
1678
meta_str = json_dumps (meta , manager .options .debug_cache )
@@ -1677,8 +1682,6 @@ def write_cache_meta(
1677
1682
# The next run will simply find the cache entry out of date.
1678
1683
manager .log (f"Error writing meta JSON file { meta_json } " )
1679
1684
1680
- return cache_meta_from_dict (meta , data_json )
1681
-
1682
1685
1683
1686
"""Dependency manager.
1684
1687
@@ -1864,9 +1867,6 @@ class State:
1864
1867
# List of (path, line number) tuples giving context for import
1865
1868
import_context : list [tuple [str , int ]]
1866
1869
1867
- # The State from which this module was imported, if any
1868
- caller_state : State | None = None
1869
-
1870
1870
# If caller_state is set, the line number in the caller where the import occurred
1871
1871
caller_line = 0
1872
1872
@@ -1917,7 +1917,6 @@ def __init__(
1917
1917
self .manager = manager
1918
1918
State .order_counter += 1
1919
1919
self .order = State .order_counter
1920
- self .caller_state = caller_state
1921
1920
self .caller_line = caller_line
1922
1921
if caller_state :
1923
1922
self .import_context = caller_state .import_context .copy ()
@@ -2008,11 +2007,6 @@ def __init__(
2008
2007
self .parse_file (temporary = temporary )
2009
2008
self .compute_dependencies ()
2010
2009
2011
- @property
2012
- def xmeta (self ) -> CacheMeta :
2013
- assert self .meta , "missing meta on allegedly fresh module"
2014
- return self .meta
2015
-
2016
2010
def add_ancestors (self ) -> None :
2017
2011
if self .path is not None :
2018
2012
_ , name = os .path .split (self .path )
@@ -2479,7 +2473,7 @@ def valid_references(self) -> set[str]:
2479
2473
2480
2474
return valid_refs
2481
2475
2482
- def write_cache (self ) -> tuple [dict [str , Any ], str , str ] | None :
2476
+ def write_cache (self ) -> tuple [dict [str , Any ], str ] | None :
2483
2477
assert self .tree is not None , "Internal error: method must be called on parsed file only"
2484
2478
# We don't support writing cache files in fine-grained incremental mode.
2485
2479
if (
@@ -3477,14 +3471,13 @@ def process_stale_scc(graph: Graph, scc: list[str], manager: BuildManager) -> No
3477
3471
for id in stale :
3478
3472
meta_tuple = meta_tuples [id ]
3479
3473
if meta_tuple is None :
3480
- graph [id ].meta = None
3481
3474
continue
3482
- meta , meta_json , data_json = meta_tuple
3475
+ meta , meta_json = meta_tuple
3483
3476
meta ["dep_hashes" ] = {
3484
3477
dep : graph [dep ].interface_hash for dep in graph [id ].dependencies if dep in graph
3485
3478
}
3486
3479
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 )
3488
3481
3489
3482
3490
3483
def sorted_components (
0 commit comments