PyCQA / flake8-import-order

Flake8 plugin that checks import order against various Python Style Guides
GNU Lesser General Public License v3.0
278 stars 72 forks source link

Comparison of str < None on Python 3 #15

Closed jodal closed 10 years ago

jodal commented 10 years ago

I'm running flake8-import-order on Python 3.4:

$ flake8 --version
2.2.2 (pep8: 1.5.7, import-order: 0.4.2, pyflakes: 0.8.1, mccabe: 0.2.1) CPython 3.4.0 on Linux

And it crashes because of a comparison of str and None:

$ flake8 
Traceback (most recent call last):
  File "/home/jodal/dev/virtualenvs/vega3/bin/flake8", line 11, in <module>
    sys.exit(main())
  File "/home/jodal/dev/virtualenvs/vega3/lib/python3.4/site-packages/flake8/main.py", line 32, in main
    report = flake8_style.check_files()
  File "/home/jodal/dev/virtualenvs/vega3/lib/python3.4/site-packages/pep8.py", line 1670, in check_files
    self.input_dir(path)
  File "/home/jodal/dev/virtualenvs/vega3/lib/python3.4/site-packages/pep8.py", line 1706, in input_dir
    runner(os.path.join(root, filename))
  File "/home/jodal/dev/virtualenvs/vega3/lib/python3.4/site-packages/flake8/engine.py", line 83, in input_file
    return fchecker.check_all(expected=expected, line_offset=line_offset)
  File "/home/jodal/dev/virtualenvs/vega3/lib/python3.4/site-packages/pep8.py", line 1412, in check_all
    self.check_ast()
  File "/home/jodal/dev/virtualenvs/vega3/lib/python3.4/site-packages/pep8.py", line 1359, in check_ast
    for lineno, offset, text, check in checker.run():
  File "/home/jodal/dev/virtualenvs/vega3/lib/python3.4/site-packages/flake8_import_order/flake8_linter.py", line 49, in run
    for error in self.check_order():
  File "/home/jodal/dev/virtualenvs/vega3/lib/python3.4/site-packages/flake8_import_order/__init__.py", line 206, in check_order
    if n < pn:
TypeError: unorderable types: str() < NoneType()

But it works when running flake8 with Python 2.7 on the same code base:

$ flake8 --version
2.2.2 (pep8: 1.5.7, mccabe: 0.2.1, import-order: 0.4.2, pyflakes: 0.8.1) CPython 2.7.6 on Linux
$ flake8 
$ echo $?
0
public commented 10 years ago

Any chance you can figure out the file it's linting when it crashes? This plugin is used on several Python 3 projects where it works fine.

untitaker commented 10 years ago

Running flake8 on Python 3:

from . import a
from .x import b
untitaker commented 10 years ago

Very likely that this is not failing in Py2 because everything is larger than None there.

public commented 10 years ago

Will do a release Soon (tm).