spulec / pep8ify

A library that modifies python source code to conform to pep8.
Apache License 2.0
118 stars 12 forks source link

pep8ify crashes on simple input #17

Closed alex closed 10 years ago

alex commented 10 years ago

Here's the code:

# Copyright 2013 Donald Stufft
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import, division, print_function
from __future__ import unicode_literals

import psycopg2cffi.compat

from warehouse.__about__ import (
    __title__, __summary__, __uri__, __version__, __author__, __email__,
    __license__, __copyright__, __build__,
)

__all__ = [
    "__title__", "__summary__", "__uri__", "__version__", "__author__",
    "__email__", "__license__", "__copyright__", "__build__",
]

psycopg2cffi.compat.register()

And the traceback:

$ pep8ify warehouse/__init__.py
RefactoringTool: Skipping implicit fixer: maximum_line_length
Traceback (most recent call last):
  File "/Users/alex_gaynor/.virtualenvs/tempenv-6c9a3044561e1/bin/pep8ify", line 9, in <module>
    load_entry_point('pep8ify==0.0.10', 'console_scripts', 'pep8ify')()
  File "/Users/alex_gaynor/.virtualenvs/tempenv-6c9a3044561e1/lib/python2.7/site-packages/pep8ify/pep8ify.py", line 12, in _main
    sys.exit(main("pep8ify.fixes"))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib2to3/main.py", line 260, in main
    options.processes)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib2to3/refactor.py", line 706, in refactor
    items, write, doctests_only)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib2to3/refactor.py", line 301, in refactor
    self.refactor_file(dir_or_file, write, doctests_only)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib2to3/refactor.py", line 747, in refactor_file
    *args, **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib2to3/refactor.py", line 354, in refactor_file
    tree = self.refactor_string(input, filename)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib2to3/refactor.py", line 386, in refactor_string
    self.refactor_tree(tree, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib2to3/refactor.py", line 426, in refactor_tree
    self.traverse_by(self.bmi_post_order_heads, tree.post_order())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib2to3/refactor.py", line 500, in traverse_by
    results = fixer.match(node)
  File "/Users/alex_gaynor/.virtualenvs/tempenv-6c9a3044561e1/lib/python2.7/site-packages/pep8ify/fixes/fix_whitespace_before_inline_comment.py", line 36, in match
    prev_node = get_previous_node(node)
  File "/Users/alex_gaynor/.virtualenvs/tempenv-6c9a3044561e1/lib/python2.7/site-packages/pep8ify/fixes/fix_whitespace_before_inline_comment.py", line 12, in get_previous_node
    return get_previous_node(node.parent)
  File "/Users/alex_gaynor/.virtualenvs/tempenv-6c9a3044561e1/lib/python2.7/site-packages/pep8ify/fixes/fix_whitespace_before_inline_comment.py", line 12, in get_previous_node
    return get_previous_node(node.parent)
  File "/Users/alex_gaynor/.virtualenvs/tempenv-6c9a3044561e1/lib/python2.7/site-packages/pep8ify/fixes/fix_whitespace_before_inline_comment.py", line 12, in get_previous_node
    return get_previous_node(node.parent)
  File "/Users/alex_gaynor/.virtualenvs/tempenv-6c9a3044561e1/lib/python2.7/site-packages/pep8ify/fixes/fix_whitespace_before_inline_comment.py", line 12, in get_previous_node
    return get_previous_node(node.parent)
  File "/Users/alex_gaynor/.virtualenvs/tempenv-6c9a3044561e1/lib/python2.7/site-packages/pep8ify/fixes/fix_whitespace_before_inline_comment.py", line 10, in get_previous_node
    if node.prev_sibling:
AttributeError: 'NoneType' object has no attribute 'prev_sibling'
spulec commented 10 years ago

Thanks! Sorry for the issues lately.

alex commented 10 years ago

No problem, thanks for the quick fix!