Skip to content

Commit

Permalink
bears/general: Use string.expandtabs()
Browse files Browse the repository at this point in the history
SpacingHelper.replace_tabs_with_spaces is a less efficient
implementation of string.expandtabs(), and should be deprecated.
  • Loading branch information
jayvdb authored and gitmate-bot committed Feb 21, 2018
1 parent 5a4115e commit f30ad47
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions bears/general/LineLengthBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ def run(self,
:param ignore_length_regex: Lines matching each of the regular
expressions in this list will be ignored.
'''
spacing_helper = SpacingHelper(indent_size)
ignore_regexes = [re.compile(regex) for regex in ignore_length_regex]

for line_number, line in enumerate(file):
line = spacing_helper.replace_tabs_with_spaces(line)
line = line.expandtabs(indent_size)
if len(line) > max_line_length + 1:
if any(regex.search(line) for regex in ignore_regexes):
continue
Expand Down
3 changes: 1 addition & 2 deletions bears/general/SpaceConsistencyBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ def run(self,

if use_spaces:
pre_replacement = replacement
replacement = spacing_helper.replace_tabs_with_spaces(
replacement)
replacement = replacement.expandtabs(indent_size)
if replacement != pre_replacement:
result_texts.append('Tabs used instead of spaces.')
else:
Expand Down

0 comments on commit f30ad47

Please sign in to comment.