@@ -51,6 +51,9 @@ class ErrorInfo:
51
51
# Only report this particular messages once per program.
52
52
only_once = False
53
53
54
+ # Actual origin of the error message
55
+ origin = None # type: Tuple[str, int]
56
+
54
57
# Fine-grained incremental target where this was reported
55
58
target = None # type: Optional[str]
56
59
@@ -291,13 +294,13 @@ def report(self,
291
294
target = self .current_target ())
292
295
self .add_error_info (info )
293
296
294
- def _add_error_info (self , info : ErrorInfo ) -> None :
295
- if info . file not in self .error_info_map :
296
- self .error_info_map [info . file ] = []
297
- self .error_info_map [info . file ].append (info )
297
+ def _add_error_info (self , file : str , info : ErrorInfo ) -> None :
298
+ if file not in self .error_info_map :
299
+ self .error_info_map [file ] = []
300
+ self .error_info_map [file ].append (info )
298
301
299
302
def add_error_info (self , info : ErrorInfo ) -> None :
300
- ( file , line ) = cast ( Tuple [ str , int ], info .origin ) # see issue 1855
303
+ file , line = info .origin
301
304
if not info .blocker : # Blockers cannot be ignored
302
305
if file in self .ignored_lines and line in self .ignored_lines [file ]:
303
306
# Annotation requests us to ignore all errors on this line.
@@ -309,7 +312,7 @@ def add_error_info(self, info: ErrorInfo) -> None:
309
312
if info .message in self .only_once_messages :
310
313
return
311
314
self .only_once_messages .add (info .message )
312
- self ._add_error_info (info )
315
+ self ._add_error_info (file , info )
313
316
314
317
def generate_unused_ignore_notes (self , file : str ) -> None :
315
318
ignored_lines = self .ignored_lines [file ]
@@ -319,7 +322,7 @@ def generate_unused_ignore_notes(self, file: str) -> None:
319
322
info = ErrorInfo (self .import_context (), file , self .current_module (), None ,
320
323
None , line , - 1 , 'note' , "unused 'type: ignore' comment" ,
321
324
False , False )
322
- self ._add_error_info (info )
325
+ self ._add_error_info (file , info )
323
326
324
327
def is_typeshed_file (self , file : str ) -> bool :
325
328
# gross, but no other clear way to tell
0 commit comments