161
161
from mypy .server .deps import get_dependencies_of_target , merge_dependencies
162
162
from mypy .server .target import trigger_to_target
163
163
from mypy .server .trigger import WILDCARD_TAG , make_trigger
164
- from mypy .typeanal import remove_dups
165
164
from mypy .typestate import type_state
166
165
from mypy .util import module_prefix , split_target
167
166
@@ -245,7 +244,7 @@ def update(
245
244
246
245
self .triggered = []
247
246
self .updated_modules = []
248
- changed_modules = remove_dups (changed_modules + self .stale )
247
+ changed_modules = dedupe_modules (changed_modules + self .stale )
249
248
initial_set = {id for id , _ in changed_modules }
250
249
self .manager .log_fine_grained (
251
250
"==== update %s ====" % ", " .join (repr (id ) for id , _ in changed_modules )
@@ -260,7 +259,7 @@ def update(
260
259
# Handle blocking errors first. We'll exit as soon as we find a
261
260
# module that still has blocking errors.
262
261
self .manager .log_fine_grained (f"existing blocker: { self .blocking_error [0 ]} " )
263
- changed_modules = remove_dups ([self .blocking_error ] + changed_modules )
262
+ changed_modules = dedupe_modules ([self .blocking_error ] + changed_modules )
264
263
blocking_error = self .blocking_error [0 ]
265
264
self .blocking_error = None
266
265
@@ -295,7 +294,7 @@ def update(
295
294
self .previous_targets_with_errors ,
296
295
self .processed_targets ,
297
296
)
298
- changed_modules = remove_dups (changed_modules )
297
+ changed_modules = dedupe_modules (changed_modules )
299
298
if not changed_modules :
300
299
# Preserve state needed for the next update.
301
300
self .previous_targets_with_errors = self .manager .errors .targets ()
@@ -370,7 +369,7 @@ def update_one(
370
369
result = self .update_module (next_id , next_path , next_id in removed_set , followed )
371
370
remaining , (next_id , next_path ), blocker_messages = result
372
371
changed_modules = [(id , path ) for id , path in changed_modules if id != next_id ]
373
- changed_modules = remove_dups (remaining + changed_modules )
372
+ changed_modules = dedupe_modules (remaining + changed_modules )
374
373
t1 = time .time ()
375
374
376
375
self .manager .log_fine_grained (
@@ -727,6 +726,16 @@ def delete_module(module_id: str, path: str, graph: Graph, manager: BuildManager
727
726
manager .missing_modules .add (module_id )
728
727
729
728
729
+ def dedupe_modules (modules : list [tuple [str , str ]]) -> list [tuple [str , str ]]:
730
+ seen : set [str ] = set ()
731
+ result = []
732
+ for id , path in modules :
733
+ if id not in seen :
734
+ seen .add (id )
735
+ result .append ((id , path ))
736
+ return result
737
+
738
+
730
739
def get_module_to_path_map (graph : Graph ) -> dict [str , str ]:
731
740
return {module : node .xpath for module , node in graph .items ()}
732
741
0 commit comments