Skip to content

Commit

Permalink
Remove get_line() and get_column() functions (#14071)
Browse files Browse the repository at this point in the history
When I was working on a different PR for Mypy, I came across these
functions:

```python
    def get_line(self) -> int:
        """Don't use. Use x.line."""
        return self.line

    def get_column(self) -> int:
        """Don't use. Use x.column."""
        return self.column
```

So I just went ahead and removed them.
  • Loading branch information
dosisod authored Nov 16, 2022
1 parent 6a7c7cd commit f84f00a
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 16 deletions.
4 changes: 2 additions & 2 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ def span_from_context(ctx: Context) -> tuple[int, int]:
else:
origin_span = None
self.errors.report(
context.get_line() if context else -1,
context.get_column() if context else -1,
context.line if context else -1,
context.column if context else -1,
msg,
severity=severity,
file=file,
Expand Down
8 changes: 0 additions & 8 deletions mypy/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,6 @@ def set_line(
if end_column is not None:
self.end_column = end_column

def get_line(self) -> int:
"""Don't use. Use x.line."""
return self.line

def get_column(self) -> int:
"""Don't use. Use x.column."""
return self.column


if TYPE_CHECKING:
# break import cycle only needed for mypy
Expand Down
2 changes: 1 addition & 1 deletion mypy/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def indentation_level(self, line_number: int) -> int | None:
return None

def visit_func_def(self, defn: FuncDef) -> None:
start_line = defn.get_line() - 1
start_line = defn.line - 1
start_indent = None
# When a function is decorated, sometimes the start line will point to
# whitespace or comments between the decorator and the function, so
Expand Down
4 changes: 2 additions & 2 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6109,12 +6109,12 @@ def fail(
return
# In case it's a bug and we don't really have context
assert ctx is not None, msg
self.errors.report(ctx.get_line(), ctx.get_column(), msg, blocker=blocker, code=code)
self.errors.report(ctx.line, ctx.column, msg, blocker=blocker, code=code)

def note(self, msg: str, ctx: Context, code: ErrorCode | None = None) -> None:
if not self.in_checked_function():
return
self.errors.report(ctx.get_line(), ctx.get_column(), msg, severity="note", code=code)
self.errors.report(ctx.line, ctx.column, msg, severity="note", code=code)

def incomplete_feature_enabled(self, feature: str, ctx: Context) -> bool:
if feature not in self.options.enable_incomplete_feature:
Expand Down
2 changes: 1 addition & 1 deletion mypy/semanal_typeargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,4 @@ def check_type_var_values(
)

def fail(self, msg: str, context: Context, *, code: ErrorCode | None = None) -> None:
self.errors.report(context.get_line(), context.get_column(), msg, code=code)
self.errors.report(context.line, context.column, msg, code=code)
2 changes: 1 addition & 1 deletion mypy/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def visit_func_def(self, o: FuncDef) -> None:
if o in o.expanded:
print(
"{}:{}: ERROR: cycle in function expansion; skipping".format(
self.filename, o.get_line()
self.filename, o.line
)
)
return
Expand Down
2 changes: 1 addition & 1 deletion mypy/strconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def dump(self, nodes: Sequence[object], obj: mypy.nodes.Context) -> str:
number. See mypy.util.dump_tagged for a description of the nodes
argument.
"""
tag = short_type(obj) + ":" + str(obj.get_line())
tag = short_type(obj) + ":" + str(obj.line)
if self.show_ids:
assert self.id_mapper is not None
tag += f"<{self.get_id(obj)}>"
Expand Down

0 comments on commit f84f00a

Please sign in to comment.