From 31ec751c166521fc8aa5399855225bb3d39c9a46 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sat, 29 Jan 2022 19:40:16 +0100 Subject: [PATCH] Remove superfluous custom `accumulate` function --- linter.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/linter.py b/linter.py index 82eb91f..e2e73df 100644 --- a/linter.py +++ b/linter.py @@ -11,7 +11,7 @@ """This module exports the Annotations plugin class.""" -from itertools import accumulate as accumulate_, chain +from itertools import accumulate, chain import re from SublimeLinter.lint import Linter, LintMatch @@ -19,7 +19,7 @@ MYPY = False if MYPY: - from typing import Iterable, Iterator, List, Union + from typing import Iterator, List, Union from SublimeLinter.lint import util @@ -79,7 +79,7 @@ def find_errors(self, output): for region in regions: region_text = self.view.substr(region) lines = region_text.splitlines(keepends=True) - offsets = accumulate(map(len, lines), initial=region.a) + offsets = accumulate(chain([region.a], map(len, lines))) for line, offset in zip(lines, offsets): match = mark_regex.search(line) if not match: @@ -99,11 +99,3 @@ def find_errors(self, output): code=word, message=message ) - - -def accumulate(iterable, initial=None): - # type: (Iterable[int], int) -> Iterable[int] - if initial is None: - return accumulate_(iterable) - else: - return accumulate_(chain([initial], iterable))