Skip to content

Commit

Permalink
local variable
Browse files Browse the repository at this point in the history
  • Loading branch information
superlopuh committed Dec 11, 2024
1 parent 4d6e9b1 commit cb51b8c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions xdsl/utils/base_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
from dataclasses import dataclass, field
from typing import IO, Any, TypeVar

indentNumSpaces = 2


@dataclass(eq=False, repr=False)
class BasePrinter:
stream: IO[str] | None = field(default=None)
indent_num_spaces: int = field(default=2, kw_only=True)
_indent: int = field(default=0, init=False)
_current_line: int = field(default=0, init=False)
_current_column: int = field(default=0, init=False)
Expand Down Expand Up @@ -78,7 +77,7 @@ def _print_new_line(
for callback in self._next_line_callback:
callback()
self._next_line_callback = []
num_spaces = indent * indentNumSpaces
num_spaces = indent * self.indent_num_spaces
# Prints indentation, bypassing the `print_string` method
print(" " * num_spaces, end="", file=self.stream)
self._current_column = num_spaces
Expand Down Expand Up @@ -116,7 +115,7 @@ def _print_message(
The span of the message to be underlined is represented as [begin_pos, end_pos).
"""
indent = self._indent if indent is None else indent
indent_size = indent * indentNumSpaces
indent_size = indent * self.indent_num_spaces
self.print_string(" " * indent_size)
message_end_pos = max(map(len, message.split("\n"))) + indent_size + 2
first_line = (
Expand Down

0 comments on commit cb51b8c

Please sign in to comment.