Skip to content

Commit ff4e909

Browse files
committed
Do not display import-not-found after module-level always false assert
1 parent 5e9d657 commit ff4e909

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

mypy/errors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,8 @@ def add_error_info(self, info: ErrorInfo) -> None:
633633
return
634634
if file in self.ignored_files:
635635
return
636+
if file in self.skipped_lines and set(lines) <= self.skipped_lines[file]:
637+
return
636638
if info.only_once:
637639
if info.message in self.only_once_messages:
638640
return

test-data/unit/check-unreachable-code.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,13 @@ assert sys.platform == 'lol'
778778
def bar() -> None: pass
779779
[builtins fixtures/ops.pyi]
780780

781+
[case testUnreachableAfterToplevelAssertImportThirdParty]
782+
# flags: --platform unknown
783+
import sys
784+
assert sys.platform == 'linux'
785+
import does_not_exist
786+
[builtins fixtures/ops.pyi]
787+
781788
[case testUnreachableAfterToplevelAssertNotInsideIf]
782789
import sys
783790
if sys.version_info[0] >= 2:

0 commit comments

Comments
 (0)