Skip to content

Commit

Permalink
Move the off-by-one to where the offset is set rather than in the err…
Browse files Browse the repository at this point in the history
…or display
  • Loading branch information
Qalthos committed Sep 15, 2023
1 parent c3d4dea commit 99dff9d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ansiblelint/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def __post_init__(self) -> None:
msg = "MatchError called incorrectly as column numbers start with 1"
raise RuntimeError(msg)

offset = getattr(self.lintable, "_line_offset", 1)
self.lineno += offset - 1
offset = getattr(self.lintable, "_line_offset", 0)
self.lineno += offset

@functools.cached_property
def level(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def parse_examples_from_plugin(self) -> str:
if isinstance(child, ast.Assign):
label = child.targets[0]
if isinstance(label, ast.Name) and label.id == "EXAMPLES":
self._line_offset = child.lineno
self._line_offset = child.lineno - 1
break

docs = read_docstring(str(self.path))
Expand Down

0 comments on commit 99dff9d

Please sign in to comment.