(
self, file: str, is_warning_unused_ignores: bool, is_typeshed: bool = False
)
| 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.""" |
no test coverage detected