Return an iterator over (line number, line text) from a Python file.
(path: str)
| 144 | |
| 145 | |
| 146 | def iterate_python_lines(path: str) -> Iterator[tuple[int, str]]: |
| 147 | """Return an iterator over (line number, line text) from a Python file.""" |
| 148 | if not os.path.isdir(path): # can happen with namespace packages |
| 149 | with tokenize.open(path) as input_file: |
| 150 | yield from enumerate(input_file, 1) |
| 151 | |
| 152 | |
| 153 | class FuncCounterVisitor(TraverserVisitor): |