Whole file
terryyin/lizard
The author described this change as “Fixing bug when python has multiple line for function declaration due to formatting (#319)”. It counts as a record because the check below fails on the code as it stood at 79ecdc28d and passes on c900ecc9b, with nothing else changed between the two runs.
Projectterryyin/lizard
Fix saved2021-05-31
Sharing licenceMIT · LICENSE.txt
Change size+3 −3
What the code was meant to do, written into the code itself as a save note
Fixing bug when python has multiple line for function declaration due to formatting (#319)
The change
| 13 | 13 | self.indents = [0] | |
| 14 | 14 | self.context = context | |
| 15 | 15 | ||
| 16 | - | def set_nesting(self, spaces): | |
| 17 | - | while self.indents[-1] > spaces: | |
| 16 | + | def set_nesting(self, spaces, token = ""): | |
| 17 | + | while self.indents[-1] > spaces and (not token.startswith(")")): | |
| 18 | 18 | self.indents.pop() | |
| 19 | 19 | self.context.pop_nesting() | |
| 20 | 20 | if self.indents[-1] < spaces: | |
| ⋯ | |||
| 53 | 53 | current_leading_spaces += count_spaces(token) | |
| 54 | 54 | else: | |
| 55 | 55 | if not token.startswith('#'): | |
| 56 | - | indents.set_nesting(current_leading_spaces) | |
| 56 | + | indents.set_nesting(current_leading_spaces, token) | |
| 57 | 57 | reading_leading_space = False | |
| 58 | 58 | else: | |
| 59 | 59 | reading_leading_space = True | |
The check that tells the two apart
fail→pass·test/test_languages/testPython.py::Test_parser_for_Python::test_multi_line_function_def_function_end
Check file test/test_languages/testPython.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it79ecdc28ddbd313358ecc79971add3f8dafa088c
Broken version dated2021-05-14
Modulelizard_languages.python
Units changedPythonIndents, PythonReader
Fingerprint2f25ca6bead08153
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in terryyin/lizard
- 2026-08-08fix(java): do not report control structures as methods
- 2026-07-02HalsteadClassifier
- 2026-07-02fix(csv): emit columns for extensions with multiple FUNCTION_INFO fields
- 2026-06-15fix(golike): register generic functions with [...] type params
- 2026-06-15fix(java): enhance parsing of generic and qualified type names in anonymous classes
- 2026-06-11fix(script): stop a '#' comment continuing past a trailing backslash (#317)