I was trying to program certain code in which I have to find the exact location of row and column number where the indentation error has occurred by reading a python file with indentation error into another Python file. Any inputs for finding this
Asked
Active
Viewed 69 times
0
-
does this answer your question: https://stackoverflow.com/questions/8503559/what-is-linting#:~:text=Linting%20is%20the%20process%20of,in%20C%20language%20source%20code. – warped May 14 '21 at 15:24
-
As far as I know, linting would only look at the first indentation error? – hypadr1v3 May 14 '21 at 15:25
1 Answers
1
You could use pycodestyle and look for error codes related to indentation such as E112 and E113.
In the example below I'm using flake8 of which pycodestyle is a sub-tool.
$ cat << EOF > malformed.py
> def foo():
> return 1 + 1
>
> def other():
> if 1 < 2:
> return None
> EOF
$ python -m flake8 malformed.py | grep E1
malformed.py:2:1: E112 expected an indented block
malformed.py:6:1: E112 expected an indented block
(Or, the --select flag can accept a comma-separated list of errors and warnings to enable.)
Brad Solomon
- 34,372
- 28
- 129
- 206