Skip to content

Commit

Permalink
fixed list parameters last line parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Gal Ben David committed Nov 11, 2020
1 parent 30d0275 commit db6be80
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
12 changes: 11 additions & 1 deletion flake8_intsights/checkers/declerations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import astroid
import tokenize

from . import _checker

Expand Down Expand Up @@ -297,7 +298,16 @@ def ensure_sub_elements(
column_offset=list_entry_node.col_offset,
)

list_entry_line = lines[list_entry_node.lineno - 1]
list_entry_token = cls.get_token_by_position(
lineno=list_entry_node.lineno,
col_offset=list_entry_node.col_offset,
tokens=tokens,
)
if list_entry_token.type == tokenize.STRING:
list_entry_line = lines[list_entry_token.end[0] - 1]
else:
list_entry_line = lines[list_entry_node.lineno - 1]

if list_entry_line.strip() in cls.OPENERS:
list_closer_token = cls.get_node_closer_token(
node=list_entry_node,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setuptools.setup(
name='flake8-intsights',
version='0.1.2',
version='0.1.3',
author='Gal Ben David',
author_email='[email protected]',
url='https://github.com/Intsights/flake8-intsights',
Expand Down
10 changes: 10 additions & 0 deletions tests/test_declerations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1347,3 +1347,13 @@ def test_case_107(
),
second=[],
)

def test_case_108(
self,
):
self.assertEqual(
first=self.get_linting_errors(
source_code=texts.declerations.declerations_test_text_108,
),
second=[],
)
12 changes: 12 additions & 0 deletions tests/texts/declerations.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,3 +744,15 @@ class Class:
async def function():
pass
'''
declerations_test_text_108 = '''
list_a = [
\'\'\'
multiline
string
\'\'\',
\'\'\'
multiline
string
\'\'\',
]
'''

0 comments on commit db6be80

Please sign in to comment.