MCPcopy Index your code
hub / github.com/python/mypy / generate_ignore_without_code_errors

Method generate_ignore_without_code_errors

mypy/errors.py:938–963  ·  view source on GitHub ↗
(
        self, file: str, is_warning_unused_ignores: bool, is_typeshed: bool = False
    )

Source from the content-addressed store, hash-verified

936 self.report_simple_error(file, line, message, code=codes.UNUSED_IGNORE)
937
938 def generate_ignore_without_code_errors(
939 self, file: str, is_warning_unused_ignores: bool, is_typeshed: bool = False
940 ) -> None:
941 if is_typeshed or file in self.ignored_files:
942 return
943
944 used_ignored_lines = self.used_ignored_lines[file]
945 for line, ignored_codes in self.ignored_lines[file].items():
946 if line in self.skipped_lines[file]:
947 continue
948 if ignored_codes:
949 continue
950
951 # If the `type: ignore` is itself unused and that would be warned about,
952 # let that error stand alone
953 if is_warning_unused_ignores and not used_ignored_lines[line]:
954 continue
955
956 codes_hint = ""
957 ignored_codes = sorted(set(used_ignored_lines[line]))
958 if ignored_codes:
959 codes_hint = f' (consider "type: ignore[{", ".join(ignored_codes)}]" instead)'
960
961 message = f'"type: ignore" comment without error code{codes_hint}'
962 # Don't use report() since add_error_info will ignore the error!
963 self.report_simple_error(file, line, message, code=codes.IGNORE_WITHOUT_CODE)
964
965 def num_messages(self) -> int:
966 """Return the number of generated messages."""

Callers 1

Calls 5

report_simple_errorMethod · 0.95
sortedFunction · 0.85
setClass · 0.85
itemsMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected