File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1493,6 +1493,9 @@ def is_unannotated_any(t: Type) -> bool:
14931493 show_untyped = not self .is_typeshed_stub or self .options .warn_incomplete_stub
14941494 check_incomplete_defs = self .options .disallow_incomplete_defs and has_explicit_annotation
14951495 if show_untyped and (self .options .disallow_untyped_defs or check_incomplete_defs ):
1496+ # TODO: changing end line and column here changes this information for the node itself
1497+ # fdef.end_line = fdef.line
1498+ # fdef.end_column = fdef.column + 1
14961499 if fdef .type is None and self .options .disallow_untyped_defs :
14971500 if not fdef .arguments or (
14981501 len (fdef .arguments ) == 1
Original file line number Diff line number Diff line change @@ -256,16 +256,28 @@ def span_from_context(ctx: Context) -> Iterable[int]:
256256 assert origin_span is not None
257257 origin_span = itertools .chain (origin_span , span_from_context (secondary_context ))
258258
259+ column = context .column if context else - 1
260+ end_line = context .end_line if context else - 1
261+ end_column = context .end_column if context else - 1
262+
263+ # set end line and column to same as start of context for function definitions
264+ # this avoids errors being reported in IDEs for the whole function
265+ # TODO: figure out if it's possible to find the end of the function definition line
266+ if isinstance (context , FuncDef ):
267+ end_line = context .line
268+ # column is 1-based, see also format_messages in errors.py
269+ end_column = column + 1
270+
259271 self .errors .report (
260272 context .line if context else - 1 ,
261- context . column if context else - 1 ,
273+ column ,
262274 msg ,
263275 severity = severity ,
264276 file = file ,
265277 offset = offset ,
266278 origin_span = origin_span ,
267- end_line = context . end_line if context else - 1 ,
268- end_column = context . end_column if context else - 1 ,
279+ end_line = end_line ,
280+ end_column = end_column ,
269281 code = code ,
270282 allow_dups = allow_dups ,
271283 )
Original file line number Diff line number Diff line change @@ -187,8 +187,8 @@ if int():
187187 def g(x):
188188 pass
189189[out]
190- main:3:5:3:15 : error: Function is missing a return type annotation
191- main:6:5:6:10 : error: Function is missing a type annotation
190+ main:3:5:3:5 : error: Function is missing a return type annotation
191+ main:6:5:6:5 : error: Function is missing a type annotation
192192
193193[case testColumnNameIsNotDefined]
194194((x)) # E:3: Name "x" is not defined
You can’t perform that action at this time.
0 commit comments