8000 Do not show unused-ignore errors in unreachable code, and make it a real error code by ilevkivskyi · Pull Request #15164 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Do not show unused-ignore errors in unreachable code, and make it a real error code #15164

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 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
Prev Previous commit
Next Next commit
Normalize decorators; update parse tests
  • Loading branch information
ilevkivskyi committed May 1, 2023
commit 8bf51bd928eeca2d9d5fa4f648c77b33517b8d1b
8 changes: 8 additions & 0 deletions mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,14 @@ def set_block_lines(self, b: Block, stmts: Sequence[ast3.stmt]) -> None:
b.column = first.col_offset
b.end_line = getattr(last, "end_lineno", None)
b.end_column = getattr(last, "end_col_offset", None)
if not b.body:
return
first = b.body[0]
if isinstance(first, (Decorator, OverloadedFuncDef)):
# Decorated function lines are different between Python versions.
# copy the normalization we do for them to block first lines.
b.line = first.line
b.column = first.column

def as_block(self, stmts: list[ast3.stmt]) -> Block | None:
b = None
Expand Down
20 changes: 10 additions & 10 deletions test-data/unit/merge.test
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ MypyFile:1<1>(
FuncDef:1<2>(
f
def () -> builtins.int<3>
Block:1<4>(
Block:2<4>(
PassStmt:2<5>())))
==>
MypyFile:1<0>(
Expand All @@ -50,7 +50,7 @@ MypyFile:1<1>(
FuncDef:1<2>(
f
def () -> builtins.int<3>
Block:1<6>(
Block:2<6>(
PassStmt:2<7>())))

[case testClass]
Expand All @@ -77,7 +77,7 @@ MypyFile:1<1>(
Var(self)
Var(x))
def (self: target.A<4>, x: builtins.str<5>) -> builtins.int<6>
Block:2<7>(
Block:3<7>(
PassStmt:3<8>()))))
==>
MypyFile:1<0>(
Expand All @@ -93,7 +93,7 @@ MypyFile:1<1>(
Var(self)
Var(x))
def (self: target.A<4>, x: builtins.int<6>) -> builtins.str<5>
Block:2<10>(
Block:3<10>(
PassStmt:3<11>()))))

[case testClass_typeinfo]
Expand Down Expand Up @@ -149,7 +149,7 @@ MypyFile:1<1>(
Args(
Var(self))
def (self: target.A<4>) -> target.B<5>
Block:2<6>(
Block:3<6>(
ReturnStmt:3<7>(
CallExpr:3<8>(
NameExpr(B [target.B<5>])
Expand All @@ -173,7 +173,7 @@ MypyFile:1<1>(
Args(
Var(self))
def (self: target.A<4>) -> target.B<5>
Block:3<14>(
Block:4<14>(
ExpressionStmt:4<15>(
IntExpr(1))
ReturnStmt:5<16>(
Expand Down Expand Up @@ -204,7 +204,7 @@ MypyFile:1<1>(
Args(
Var(self))
def (self: target.A<4>)
Block:2<5>(
Block:3<5>(
ExpressionStmt:3<6>(
CallExpr:3<7>(
MemberExpr:3<8>(
Expand All @@ -224,7 +224,7 @@ MypyFile:1<1>(
Args(
Var(self))
def (self: target.A<4>)
Block:2<11>(
Block:3<11>(
ExpressionStmt:3<12>(
CallExpr:3<13>(
MemberExpr:3<14>(
Expand Down Expand Up @@ -257,7 +257,7 @@ MypyFile:1<1>(
Args(
Var(self))
def (self: target.A<4>)
Block:2<5>(
Block:3<5>(
AssignmentStmt:3<6>(
MemberExpr:3<8>(
NameExpr(self [l<9>])
Expand All @@ -280,7 +280,7 @@ MypyFile:1<1>(
Args(
Var(self))
def (self: target.A<4>)
Block:2<13>(
Block:3<13>(
AssignmentStmt:3<14>(
MemberExpr:3<15>(
NameExpr(self [l<16>])
Expand Down
Loading
0