332 is the least number of lines required to cause the error on my system. If no error occurs, try increasing the number (1001 should do it, as 1000 is the default stack size limit in Python).
Expected result
The file should reformat successfully, causing the script to exit with no errors.
Actual result
The following error occurs:
Traceback (most recent call last):
File "recursion_limit.py", line 11, in <module>
format_file_contents("#a\n" * 332, options=options)
File "/path/to/reformat_gherkin/core.py", line 98, in format_file_contents
assert_stable(src_contents, dst_contents, options=options)
File "/path/to/reformat_gherkin/core.py", line 160, in assert_stable
new_dst = format_str(dst, options=options)
File "/path/to/reformat_gherkin/core.py", line 114, in format_str
return "\n".join(lines)
File "/path/to/reformat_gherkin/formatter.py", line 339, in generate
yield from self.visit(node)
File "/path/to/reformat_gherkin/formatter.py", line 349, in visit
)(node)
File "/path/to/reformat_gherkin/formatter.py", line 409, in visit_comment
next_line = next(self.visit(context))
File "/path/to/reformat_gherkin/formatter.py", line 349, in visit
)(node)
File "/path/to/reformat_gherkin/formatter.py", line 409, in visit_comment
next_line = next(self.visit(context))
File "/path/to/reformat_gherkin/formatter.py", line 349, in visit
)(node)
<snip>
File "/path/to/reformat_gherkin/formatter.py", line 409, in visit_comment
next_line = next(self.visit(context))
File "/path/to/reformat_gherkin/formatter.py", line 345, in visit
class_name = type(node).__name__
RecursionError: maximum recursion depth exceeded while calling a Python object
When reformat-gherkin tries to format a comment block of longer than 332 lines, a RecursionError occurs.
Steps to reproduce
Run the following script:
332 is the least number of lines required to cause the error on my system. If no error occurs, try increasing the number (1001 should do it, as 1000 is the default stack size limit in Python).
Expected result
The file should reformat successfully, causing the script to exit with no errors.
Actual result
The following error occurs:
Environment