jamescooke/flake8-aaa

Crashes when linting a test containing f-strings

jamescooke opened this issue · 0 comments

Found in the https://github.com/seddonym/import-linter test suite:

def test_ini_file_reader(filename, contents, expected_options):
    settings.configure(
        FILE_SYSTEM=FakeFileSystem(
            content_map={
                f'/path/to/folder/{filename}': contents,
            },
            working_directory='/path/to/folder',
        )
    )

    result = IniFileUserOptionReader().read_options()

    assert result == expected_options

Running Flake8 gives a stack trace:

  File "/home/james/active/import-linter/venv/lib/python3.6/site-packages/flake8_aaa/checker.py", line 51, in run
    for error in func.check_all():
  File "/home/james/active/import-linter/venv/lib/python3.6/site-packages/flake8_aaa/function.py", line 77, in check_all
    self.mark_bl()
  File "/home/james/active/import-linter/venv/lib/python3.6/site-packages/flake8_aaa/function.py", line 168, in mark_bl
    stringy_lines = find_stringy_lines(self.node, self.first_line_no)
  File "/home/james/active/import-linter/venv/lib/python3.6/site-packages/flake8_aaa/helpers.py", line 196, in find_stringy_lines
    str_footprints.update(build_footprint(node, first_line_no))
  File "/home/james/active/import-linter/venv/lib/python3.6/site-packages/flake8_aaa/helpers.py", line 164, in build_footprint
    get_first_token(node).start[0] - first_line_no,
  File "/home/james/active/import-linter/venv/lib/python3.6/site-packages/flake8_aaa/helpers.py", line 136, in get_first_token
    return node.first_token  # type: ignore
AttributeError: 'Str' object has no attribute 'first_token'

Removing the f-string fixes the problem.