diff --git a/flake8_intsights/checkers/declerations.py b/flake8_intsights/checkers/declerations.py index 7ed2e93..4f3c55e 100755 --- a/flake8_intsights/checkers/declerations.py +++ b/flake8_intsights/checkers/declerations.py @@ -1,4 +1,5 @@ import astroid +import tokenize from . import _checker @@ -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, diff --git a/setup.py b/setup.py index cded55d..9855a73 100755 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setuptools.setup( name='flake8-intsights', - version='0.1.2', + version='0.1.3', author='Gal Ben David', author_email='gal@intsights.com', url='https://github.com/Intsights/flake8-intsights', diff --git a/tests/test_declerations.py b/tests/test_declerations.py index 81f8edb..06c4b2e 100755 --- a/tests/test_declerations.py +++ b/tests/test_declerations.py @@ -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=[], + ) diff --git a/tests/texts/declerations.py b/tests/texts/declerations.py index 33d82dd..5bfdef1 100755 --- a/tests/texts/declerations.py +++ b/tests/texts/declerations.py @@ -744,3 +744,15 @@ class Class: async def function(): pass ''' +declerations_test_text_108 = ''' +list_a = [ + \'\'\' + multiline + string + \'\'\', + \'\'\' + multiline + string + \'\'\', +] +'''