hhatto / autopep8

A tool that automatically formats Python code to conform to the PEP 8 style guide.
https://pypi.org/project/autopep8/
MIT License
4.54k stars 291 forks source link

Infinite loop in autopep8.fix_code() #676

Closed Ultimanecat closed 1 year ago

Ultimanecat commented 1 year ago

Running the following script results in an infinite loop, as fix_lines() will add more and more spaces each iteration between "hits".

Python Code


import autopep8
txt = '''
class Buggy:
    def _buggy(self):
        for track in filter(lambda x: x._num_losses > self._tolerance
                            or (x._hit_consecutive_frames < self._min_hits and x._num_losses == self._min_hits-1),
                            self._tracker_list_current):
            pass'''
docstring = autopep8.fix_code(txt, {'ignore': ['W292', 'W291']})

Command Line and Configuration

.pep8, setup.cfg, ...

[pep8]

Command Line

$ autopep8 

Your Environment

hhatto commented 1 year ago

@Ultimanecat

Thanks for reporting.

This problem has been fixed in v2.0.2. We hope you will try the latest version.