Skip to content
Merged
Changes from all commits
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
17 changes: 3 additions & 14 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
SYMBOL_FUNCBASE_TYPES,
ArgKind,
CallExpr,
ClassDef,
Context,
Expression,
FuncDef,
Expand Down Expand Up @@ -250,20 +249,10 @@ def report(
"""

def span_from_context(ctx: Context) -> Iterable[int]:
"""This determines where a type: ignore for a given context has effect.

Current logic is a bit tricky, to keep as much backwards compatibility as
possible. We may reconsider this to always be a single line (or otherwise
simplify it) when we drop Python 3.7.

TODO: address this in follow up PR
"""
if isinstance(ctx, (ClassDef, FuncDef)):
"""This determines where a type: ignore for a given context has effect."""
if not isinstance(ctx, Expression):
return range(ctx.line, ctx.line + 1)
elif not isinstance(ctx, Expression):
return [ctx.line]
else:
return range(ctx.line, (ctx.end_line or ctx.line) + 1)
return range(ctx.line, (ctx.end_line or ctx.line) + 1)

origin_span: Iterable[int] | None
if origin is not None:
Expand Down