Skip to content

Commit

Permalink
Enable Python SyntaxError checks, move to Python 3 (#811)
Browse files Browse the repository at this point in the history
* Enable Flake8 check for SyntaxError: invalid syntax.
* Fix syntax errors and move remaining code from Python 2 to Python 3.
* Remove experimental newgui (completely replaced by the single window project).
* Remove duplicate global ignore lines for Flake8 F811 (redefinition of unused).
* Replace global ignore of Flake8 W605 (invalid escape sequence) by per-file ignores.
* Define underscore as buildin as in core.
* Add per-file ignores for F823 for boxplot code due to use of _ as unused.
* Add exclude directories as in core.
* Remove prints which are clearly debug-only (instead of updating to Python 3).
* Fix typos in or close to modified code.
* Enable Black for individually disabled files which had Python 2 syntax
  • Loading branch information
wenzeslaus committed Oct 7, 2022
1 parent 388c8b1 commit 3e6dc4c
Show file tree
Hide file tree
Showing 27 changed files with 115 additions and 4,935 deletions.
29 changes: 23 additions & 6 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ignore =
E712, # comparison to False should be 'if cond is False:' or 'if not cond:'
E722, # do not use bare 'except'
E741, # ambiguous variable name 'l'
E999, # SyntaxError: invalid syntax
F401, # 'grass.script.core.gisenv' imported but unused
F402, # import 'ant' from line 15 shadowed by loop variable
F403, # 'from ... import *' used; unable to detect undefined names
Expand All @@ -21,14 +20,11 @@ ignore =
F523, # '...'.format(...) has unused arguments at position(s): 0
F632, # use ==/!= to compare constant literals (str, bytes, int, float, tuple)
F811, # redefinition of unused 'GMessage' from line 35
F811, # redefinition of unused 'grass' from line 67
F811, # redefinition of unused 'test_getpenalty' from line 84
F811, # redefinition of unused 'transform' from line 153
F821, # undefined name '_'
F841, # local variable 'center' is assigned to but never used
W605, # invalid escape sequence '\_'


# W605 invalid escape sequence
# F823 local variable '_' defined as a builtin referenced before assignment
per-file-ignores =
src/display/d.frame/d.frame.py: E302
src/gui/wxpython/wx.wms/wmsmenu.py: W293
Expand All @@ -48,6 +44,18 @@ per-file-ignores =
src/imagery/i.nightlights.intercalibration/test_intercalibration_models.py: E302
src/imagery/i.landsat/i.landsat.download/i.landsat.download.py: E302
src/hadoop/hd/dependency.py: E211
src/raster/r.category.trim/r.category.trim.py: W605
src/raster/r.area.createweight/r.area.createweight.py: W605
src/raster/r.estimap.recreation/*/*.py: W605
src/raster/r.green/*/*.py: W605
src/raster/r.futures/r.futures.demand/r.futures.demand.py: W605
src/imagery/i.modis/libmodis/rmodislib.py: W605
src/imagery/i.landsat8.swlst/*.py: W605
src/hadoop/hd/*/*.py: W605
src/misc/m.printws/m.printws.py: W605
src/vector/v.class.mlpy/v.class.mlpy.py: W605
src/temporal/t.rast.boxplot/t.rast.boxplot.py: F823
src/raster/r.series.boxplot/r.series.boxplot.py: F823


max-line-length = 88
Expand All @@ -61,3 +69,12 @@ exclude =
ENV,
env.bak,
venv.bak,
# Build directories
bin.*,
dist.*,
OBJ.*,
# Test output directory
testreport,

builtins =
_
15 changes: 0 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,5 @@ exclude = '''
| bin\..*
| dist\..*
)/
| src/hadoop/hd/dependency.py
| src/hadoop/hd/hd.hive.select/hd.hive.select.py
| src/hadoop/hd/hdfsgrass/hdfs_grass_util.py
| src/hadoop/hd/hdfswrapper/webhdfs_hook.py
| src/gui/wxpython/wx.rdigit/rdigit/main.py
| src/gui/wxpython/wx.stream/gui_modules/ImageViewer.py
| src/gui/wxpython/wx.stream/gui_modules/rstream_panelOne.py
| src/gui/wxpython/wx.wms/parse.py
| src/gui/wxpython/wx.wms/wmsmenu.py
| src/gui/wxpython/wx.wms/LoadConfig.py
| src/gui/wxpython/newgui/wxgui.py
| src/gui/wxpython/newgui/render2.py
| src/gui/wxpython/newgui/mapwindow.py
| src/gui/wxpython/newgui/frame.py
| src/raster/r.agent/tests/test_grassland.py
)
'''

0 comments on commit 3e6dc4c

Please sign in to comment.