Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give arguments a more reasonable location #14562

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix pre-3.8 AST, self-ignore annotation, pytest-slow test case
- 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
commit 7a3d4abcbf9be08d2011a04753c54c698d20dc18
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