Skip to content

Commit

Permalink
Fix pre-3.8 AST, self-ignore annotation, pytest-slow test case
Browse files Browse the repository at this point in the history
- Only fetch python AST's end column and line when available
- Move type-ignore to the line with an argument
- Update python-slow test case to use location of argument
  • Loading branch information
koogoro committed Jan 30, 2023
1 parent 1b607e4 commit 7a3d4ab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,12 @@ def make_argument(
pos_only = True

argument = Argument(Var(arg.arg), arg_type, self.visit(default), kind, pos_only)
argument.set_line(arg.lineno, arg.col_offset, arg.end_lineno, arg.end_col_offset)
argument.set_line(
arg.lineno,
arg.col_offset,
getattr(arg, "end_lineno", None),
getattr(arg, "end_col_offset", None),
)
return argument

def fail_arg(self, msg: str, arg: ast3.arg) -> None:
Expand Down
4 changes: 2 additions & 2 deletions mypy/test/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,8 @@ class DataFileCollector(pytest.Collector):
parent: DataSuiteCollector

@classmethod # We have to fight with pytest here:
def from_parent( # type: ignore[override]
cls, parent: DataSuiteCollector, *, name: str
def from_parent(
cls, parent: DataSuiteCollector, *, name: str # type: ignore[override]
) -> DataFileCollector:
collector = super().from_parent(parent, name=name)
assert isinstance(collector, DataFileCollector)
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/daemon.test
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ bar/baz.py:4:5:attr
$ dmypy inspect foo.py:10:10 --show definition --include-span
10:1:10:12 -> bar/baz.py:6:1:test
$ dmypy inspect foo.py:14:6 --show definition --include-span --include-kind
NameExpr:14:5:14:7 -> foo.py:13:1:arg
NameExpr:14:5:14:7 -> foo.py:13:9:arg
MemberExpr:14:5:14:9 -> bar/baz.py:9:5:x, bar/baz.py:11:5:x

[file foo.py]
Expand Down

0 comments on commit 7a3d4ab

Please sign in to comment.