[GRASS-dev] [GRASS GIS] #1327: [python] DebCheck QA: undefined name 'main'

#1327: [python] DebCheck QA: undefined name 'main'
-------------------------+--------------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.2
Component: Python | Version: 6.4.0
Keywords: d.rast3d | Platform: Linux
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
(see #1311,
http://qa.debian.org/daca/pyflakes/sid/grass_6.4.0-2_i386.html)

  * ./usr/lib/grass64/etc/gui/scripts/d.rast3d:36: undefined name 'main'

thanks,
Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1327&gt;
GRASS GIS <http://grass.osgeo.org>

#1327: [python] DebCheck QA: undefined name 'main'
-------------------------+--------------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.2
Component: Python | Version: 6.4.0
Keywords: d.rast3d | Platform: Linux
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by neteler):

The script is here: etc/wxpython/scripts/d.rast3d (no idea why Debian has
it in etc/gui/...).

Differences:

d.rast3d (DebCheck QA complains):
{{{
...
from grass.script import core as grass

if __name__ == "__main__":
     options, flags = grass.parser()
     main()
}}}

p.rast (same directory, DebCheck QA does not complain):
{{{
...
import sys
import os
import grass.script as grass

def construct_command(cmd):
...
if __name__ == "__main__":
     options, flags = grass.parser()
     main()
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1327#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1327: [python] DebCheck QA: undefined name 'main'
-------------------------+--------------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.2
Component: Python | Version: 6.4.0
Keywords: d.rast3d | Platform: Linux
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by neteler):

A more recent test is at
http://qa.debian.org/daca/pyflakes/sid/grass_6.4.1-1_i386.html (note some
of those modules are no longer in 6.4.2)

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1327#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1327: [python] DebCheck QA: undefined name 'main'
---------------------------------------------------------------------+------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: minor | Milestone: 6.4.5
Component: Python | Version: 6.4.0
Keywords: d.rast3d, code analysis, pyflakes, static code analysis | Platform: Linux
      Cpu: Unspecified |
---------------------------------------------------------------------+------
Changes (by wenzeslaus):

  * keywords: d.rast3d => d.rast3d, code analysis, pyflakes, static code
               analysis
  * priority: normal => minor
  * milestone: 6.4.2 => 6.4.5

Comment:

Note that you can use `pep8`, `pyflakes`, `pylint` or `pychecker` by
yourself to check the code in order to avoid downstream reporting trivial
errors. See GRASS-specific configuration files in `tools` directory.

See also
[http://grass.osgeo.org/grass71/manuals/libpython/gunittest_testing.html
#analyzing-quality-of-source-code suggestions to test code quality] and
[https://svn.osgeo.org/grass/sandbox/wenzeslaus/grass_py_static_check.py a
script in sandbox] dedicated to this purpose. [https://qa.debian.org/daca/
DACA web page] is also interesting.

However, I'm not sure if we will ever fix this for 6.x. Some of the Python
developers are working on 7.x to minimize number of these "code smells"
for example using `pep8` or `pylint`. So, this might be wontfix for 6.x
but it is a big goal for 7.x which might be described and discussed in
several mega tickets if desired.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1327#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>