smarkets / flake8-strict

Flake8 plugin that checks Python code against a set of opinionated style rules
MIT License
10 stars 8 forks source link

Fix handling of one element lists #16

Closed jstasiak closed 8 years ago

jstasiak commented 8 years ago

Previously it'd crash with something like:

Traceback (most recent call last):
  File "flake8", line 34, in <module>
    sys.exit(flake8.main.main())
  File ".../buildout-cache/eggs/flake8-2.6.0-py2.7.egg/flake8/main.py", line 36, in main
    report = flake8_style.check_files()
  File ".../buildout-cache/eggs/flake8-2.6.0-py2.7.egg/flake8/engine.py", line 181, in check_files
    return self._retry_serial(self._styleguide.check_files, paths=paths)
  File ".../buildout-cache/eggs/flake8-2.6.0-py2.7.egg/flake8/engine.py", line 172, in _retry_serial
    return func(*args, **kwargs)
  File ".../buildout-cache/eggs/pycodestyle-2.0.0-py2.7.egg/pycodestyle.py", line 1875, in check_files
    self.input_dir(path)
  File ".../buildout-cache/eggs/pycodestyle-2.0.0-py2.7.egg/pycodestyle.py", line 1911, in input_dir
    runner(os.path.join(root, filename))
  File ".../buildout-cache/eggs/flake8-2.6.0-py2.7.egg/flake8/engine.py", line 126, in input_file
    return fchecker.check_all(expected=expected, line_offset=line_offset)
  File ".../buildout-cache/eggs/pycodestyle-2.0.0-py2.7.egg/pycodestyle.py", line 1608, in check_all
    self.check_ast()
  File ".../buildout-cache/eggs/pycodestyle-2.0.0-py2.7.egg/pycodestyle.py", line 1555, in check_ast
    for lineno, offset, text, check in checker.run():
  File ".../buildout-cache/eggs/flake8_strict-0.1.3-py2.7.egg/flake8_strict.py", line 45, in run
    for line, column, error_code in errors:
  File ".../buildout-cache/eggs/flake8_strict-0.1.3-py2.7.egg/flake8_strict.py", line 149, in _process_atom
    last_maker_element = maker.children[-1]
IndexError: tuple index out of range

Fixes https://github.com/smarkets/flake8-strict/issues/15