Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mschoettle committed May 8, 2024
1 parent 081c8cb commit b835494
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
3 changes: 0 additions & 3 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,9 +1494,6 @@ def is_unannotated_any(t: Type) -> bool:
show_untyped = not self.is_typeshed_stub or self.options.warn_incomplete_stub
check_incomplete_defs = self.options.disallow_incomplete_defs and has_explicit_annotation
if show_untyped and (self.options.disallow_untyped_defs or check_incomplete_defs):
# TODO: changing end line and column here changes this information for the node itself
# fdef.end_line = fdef.line
# fdef.end_column = fdef.column + 1
if fdef.type is None and self.options.disallow_untyped_defs:
if not fdef.arguments or (
len(fdef.arguments) == 1
Expand Down
11 changes: 5 additions & 6 deletions mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,22 +979,21 @@ def do_func_def(
_dummy_fallback,
)

# End position is always the same.
end_line = getattr(n, "end_lineno", None)
end_column = getattr(n, "end_col_offset", None)

# Determine end of the function definition itself
# Fall back to the end of the function definition including its body
# End line and column span the whole function including its body.
# Determine end of the function definition itself.
# Fall back to the end of the function definition including its body.
def_end_line: int | None = n.lineno
# TODO: to go to the end of the function name: n.col_offset + 4 + len(n.name)
def_end_column: int | None = n.col_offset

returns = n.returns
# use the return type hint if defined
# Use the return type hint if defined.
if returns is not None:
def_end_line = returns.end_lineno
def_end_column = returns.end_col_offset
# otherwise use the last argument in the function definition
# Otherwise use the last argument in the function definition.
elif len(args) > 0:
last_arg = args[-1]
initializer = last_arg.initializer
Expand Down
4 changes: 1 addition & 3 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ def span_from_context(ctx: Context) -> Iterable[int]:
end_line = context.end_line if context else -1
end_column = context.end_column if context else -1

# set end line and column to same as start of context for function definitions
# this avoids errors being reported in IDEs for the whole function
# TODO: figure out if it's possible to find the end of the function definition line
# FuncDef's end includes the body, use the def's end information if available.
if isinstance(context, FuncDef):
end_line = context.def_end_line
# column is 1-based, see also format_messages in errors.py
Expand Down

0 comments on commit b835494

Please sign in to comment.