[GRASS-dev] Python: fixing mixed tabs and spaces

Hi devs,

in several Python scripts tabs and spaces are mixed which is a problem.

Questions:
- how to find these problems: with pylint, recursively?
- how to avoid them? Perhaps we collect the respective editor settings
in a Wiki page?

Markus

On Fri, Nov 30, 2018 at 10:04 PM Markus Neteler <neteler@osgeo.org> wrote:

Hi devs,

in several Python scripts tabs and spaces are mixed which is a problem.

Questions:
- how to find these problems: with pylint, recursively?

Here an (overly) simple approach:

for i in $(ag --python -l) ; do pylint-3 --errors-only $i | grep
'inconsistent use of tabs and spaces in indentation' && echo $i ; done
E:161, 0: inconsistent use of tabs and spaces in indentation
(<string>, line 161) (syntax-error)
scripts/v.rast.stats/v.rast.stats.py
E: 40, 0: inconsistent use of tabs and spaces in indentation
(<string>, line 40) (syntax-error)
raster/r.reclass/testsuite/test_r_reclass.py

(the first has just been fixed by Anna)

- how to avoid them? Perhaps we collect the respective editor settings
in a Wiki page?

Markus

On Fri, Nov 30, 2018 at 4:46 PM Markus Neteler <neteler@osgeo.org> wrote:

On Fri, Nov 30, 2018 at 10:04 PM Markus Neteler <neteler@osgeo.org> wrote:

Hi devs,

in several Python scripts tabs and spaces are mixed which is a problem.

Questions:

  • how to find these problems: with pylint, recursively?

Here an (overly) simple approach:

for i in $(ag --python -l) ; do pylint-3 --errors-only $i | grep
‘inconsistent use of tabs and spaces in indentation’ && echo $i ; done
E:161, 0: inconsistent use of tabs and spaces in indentation
(, line 161) (syntax-error)
scripts/v.rast.stats/v.rast.stats.py
E: 40, 0: inconsistent use of tabs and spaces in indentation
(, line 40) (syntax-error)
raster/r.reclass/testsuite/test_r_reclass.py

(the first has just been fixed by Anna)

Just a note, I found it when compiling with Python 3, that was the only one which failed.

Anna

  • how to avoid them? Perhaps we collect the respective editor settings
    in a Wiki page?

Markus


grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev