Skip to content

Commit b7d6d1d

Browse files
committed
Simplify span_from_context
1 parent 0a6f9ab commit b7d6d1d

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

mypy/messages.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,10 @@ def report(
251251

252252
def span_from_context(ctx: Context) -> Iterable[int]:
253253
"""This determines where a type: ignore for a given context has effect.
254-
255-
Current logic is a bit tricky, to keep as much backwards compatibility as
256-
possible. We may reconsider this to always be a single line (or otherwise
257-
simplify it) when we drop Python 3.7.
258-
259-
TODO: address this in follow up PR
260254
"""
261-
if isinstance(ctx, (ClassDef, FuncDef)):
255+
if not isinstance(ctx, Expression):
262256
return range(ctx.line, ctx.line + 1)
263-
elif not isinstance(ctx, Expression):
264-
return [ctx.line]
265-
else:
266-
return range(ctx.line, (ctx.end_line or ctx.line) + 1)
257+
return range(ctx.line, (ctx.end_line or ctx.line) + 1)
267258

268259
origin_span: Iterable[int] | None
269260
if origin is not None:

0 commit comments

Comments
 (0)