diff --git a/plugin/data_types.py b/plugin/data_types.py index 38e86b8..0d144da 100644 --- a/plugin/data_types.py +++ b/plugin/data_types.py @@ -12,6 +12,7 @@ POINT = int TUPLE_REGION = Tuple[POINT, POINT] +INDENT_LEVEL = int if sys.version_info >= (3, 11): from enum import StrEnum diff --git a/plugin/view_manager.py b/plugin/view_manager.py index 8b502c7..f81a467 100644 --- a/plugin/view_manager.py +++ b/plugin/view_manager.py @@ -6,7 +6,7 @@ import sublime -from .data_types import IndentInfo, LevelStyle +from .data_types import INDENT_LEVEL, IndentInfo, LevelStyle from .helpers import get_regions_key from .indent_renderer import AbstractIndentRenderer, find_indent_renderer from .settings import get_level_colors, get_level_style @@ -17,7 +17,7 @@ def calcualte_level_regions( *, indent_info: IndentInfo | None = None, regions: Sequence[sublime.Region] | None = None, -) -> defaultdict[int, list[sublime.Region]]: +) -> defaultdict[INDENT_LEVEL, list[sublime.Region]]: """ Calculates regions of indents for each level. @@ -36,7 +36,7 @@ def calcualte_level_regions( regions = (sublime.Region(0, view.size()),) whole_content = view.substr(sublime.Region(0, view.size())) - level_regions: defaultdict[int, list[sublime.Region]] = defaultdict(list) + level_regions: defaultdict[INDENT_LEVEL, list[sublime.Region]] = defaultdict(list) for region in regions: for m in indent_info.indent_pattern_compiled.finditer(whole_content, region.begin(), region.end()): for level, level_pt in enumerate(range(m.start(), m.end(), indent_info.indent_length)):