Skip to content

Commit

Permalink
perf(strictyaml): refactor _normalize_linecol for better perf
Browse files Browse the repository at this point in the history
Fixes iterative#10109

Signed-off-by: hqdncw <[email protected]>
  • Loading branch information
hqdncw committed Dec 26, 2023
1 parent 7e3c0de commit 65a3e0e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dvc/utils/strictyaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ def _normalize_linecol(lc: "LineCol | Tuple[Any, Any]") -> Tuple[int, int]:
elif isinstance(lc, tuple):
line = int(lc[0])
col = int(lc[1])
else:
raise TypeError(f"Expected LineCol or tuple, got {lc!r}")

if not (isinstance(line, int) and isinstance(col, int)):
raise TypeError(f"Unable to determine neither line nor col ({line}:{col})")
assert isinstance(line, int)
assert isinstance(col, int)

return line + 1, col + 1

Expand Down

0 comments on commit 65a3e0e

Please sign in to comment.