PyCQA / redbaron

Bottom-up approach to refactoring in python
http://redbaron.pycqa.org/
694 stars 74 forks source link

Comment line indentation causes ParsingError #142

Closed zjooji closed 7 years ago

zjooji commented 7 years ago

Running redbaron 0.6.3. Parsing the snippet below

try:  # get 'all' referents of objects
      # note that gc.get_referents()
      # returns () for dict...-iterators
    from gc import get_referents as _getreferents
except ImportError:  # no get_referents() in Python 2.2
    def _getreferents(unused):
        return ()  # sorry, no refs

throws a ParsingError. The cause is the comments after the try statement. If you dedent the two line comments back two spaces everything parses as you would expect.

The same error appears to happen when you have an if statement where the first line is over indented with a comment

zjooji commented 7 years ago

On closer inspection the cause seems to be based in the baron library used here. I'll close this up on my way out :)