Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Do not emit unreachable warnings for lines that returnNotImplemented.#20083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Do not emit unreachable warnings for lines that returnNotImplemented.
  • Loading branch information
@tyralla
tyralla committedOct 17, 2025
commit5c4c4b1278bf92adb9b162ca92e5846a7e650e7f
2 changes: 2 additions & 0 deletionsmypy/checker.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3147,6 +3147,8 @@ def is_noop_for_reachability(self, s: Statement) -> bool:
"""
if isinstance(s, AssertStmt) and is_false_literal(s.expr):
return True
elif isinstance(s, ReturnStmt) and is_literal_not_implemented(s.expr):
return True
elif isinstance(s, (RaiseStmt, PassStmt)):
return True
elif isinstance(s, ExpressionStmt):
Expand Down
20 changes: 20 additions & 0 deletionstest-data/unit/check-unreachable-code.test
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1620,6 +1620,26 @@ reveal_type(bar().attr) # N: Revealed type is "Never"
reveal_type(foo().attr) # N: Revealed type is "Never"
1 # E: Statement is unreachable

[case testIgnoreReturningNotImplemented]
# flags: --warn-unreachable

class C:
def __add__(self, o: C) -> C:
if not isinstance(o, C):
return NotImplemented
return C()
def __sub__(self, o: C) -> C:
if isinstance(o, C):
return C()
return NotImplemented
def __mul__(self, o: C) -> C:
if isinstance(o, C):
return C()
else:
return NotImplemented

[builtins fixtures/isinstance.pyi]

[case testUnreachableStatementPrettyHighlighting]
# flags: --warn-unreachable --pretty
def x() -> None:
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp