Skip to content

Commit

Permalink
Remove superfluous custom accumulate function
Browse files Browse the repository at this point in the history
  • Loading branch information
FichteFoll committed Jan 29, 2022
1 parent ad09fec commit 31ec751
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

"""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


MYPY = False
if MYPY:
from typing import Iterable, Iterator, List, Union
from typing import Iterator, List, Union
from SublimeLinter.lint import util


Expand Down Expand Up @@ -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:
Expand All @@ -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))

0 comments on commit 31ec751

Please sign in to comment.