From cb51b8c93449db8ebe933db5de8a359d929586a8 Mon Sep 17 00:00:00 2001 From: Sasha Lopoukhine Date: Wed, 11 Dec 2024 20:32:38 +0000 Subject: [PATCH] local variable --- xdsl/utils/base_printer.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/xdsl/utils/base_printer.py b/xdsl/utils/base_printer.py index 6ad64cecba..42658b5091 100644 --- a/xdsl/utils/base_printer.py +++ b/xdsl/utils/base_printer.py @@ -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) @@ -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 @@ -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 = (