Opened 6 years ago
Last modified 5 years ago
#3804 new defect
Naming conventions for imports in GRASS codebase
Reported by: | pmav99 | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.8.3 |
Component: | Python | Version: | svn-trunk |
Keywords: | Cc: | ||
CPU: | Unspecified | Platform: | Unspecified |
Description
There is a great deal of variation in the way that grass code does imports. Just a few examples:
import grass.script as core import grass.script as gcore import grass.script as grass import grass.script as gs import grass.script as gscript import grass.script as sgrass import grass.script.core as core import grass.script.core as gcore import grass.script.core as grass import grass.script.core as gscore import grass.script.raster as grast import grass.script.raster as raster import grass.pygrass.utils as gutils import grass.pygrass.utils as utils import grass.lib.gis as gislib import grass.lib.gis as libgis
I think it would be a good idea if a certain style was picked and consistently used throughout the codebase.
Change History (3)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
TBH, apart from:
import grass.script as grass import grass.script.core as grass
which I seriously dislike, I don't have any strong opinions on the matter. I agree though that @sbl's suggestion is probably the most reasonable approach.
comment:3 by , 5 years ago
Milestone: | → 7.8.3 |
---|
Note:
See TracTickets
for help on using tickets.
Sounds very reasonable to me and should also apply to addons. That might make it a bit easier for new addon-devs.
A way to import, that can be applied at all levels while avoiding potential conflicts with other libraries would be to add a g before the names of the imported components, as it has been practice in many cases:
import grass.script as gscript
import grass.script.core as gcore
import grass.pygrass.utils as gutils
A respective guideline should be added to: https://trac.osgeo.org/grass/wiki/Submitting/Python