Skip to content

Commit

Permalink
Checks: Fix Flake8 E501 (#3541)
Browse files Browse the repository at this point in the history
Fixes E501 (line too long).

Docstrings (descriptions and parameters): fixed by using the existing format (authors' docstrings - length, parameters aligned or x indentations, etc), most of which are shorter than 88 characters.

If results in rst code-blocks and doctest exceed the limit, use  noqa: E501.

Regex, Jinja2 HTML template strings strings: noqa: E501

More noqa: E501: Strings and comments were intended to be formatted in a specific way: For example, comments were used as measuring tape for string lengths. Print statements with strings which have ASCII tables etc.

Using blackdoc for most of the code in comments.

Flake8 can ignore a line or a file, but not a function.
  • Loading branch information
mshukuno authored May 3, 2024
1 parent a351e5e commit 763fa05
Show file tree
Hide file tree
Showing 158 changed files with 3,363 additions and 2,115 deletions.
199 changes: 86 additions & 113 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ per-file-ignores =
# F841 local variable assigned to but never used
# E741 ambiguous variable name 'l'
__init__.py: F401, F403
lib/init/grass.py: E501, E722, F821, F841, W605
utils/mkrest.py: E501, W605
lib/init/grass.py: E722, F821, F841, W605
utils/mkrest.py: W605
utils/gitlog2changelog.py: E722, E712, W605
utils/g.html2man/ggroff.py: W605
man/build_check_rest.py: F403, F405
Expand All @@ -36,98 +36,87 @@ per-file-ignores =
man/build_keywords.py: F403, F405, E722
man/build_topics.py: F403, F405, E722
man/build_html.py: E501
man/build_rest.py: E501
imagery/i.atcorr/create_iwave.py: E501, F632, F821, W293
imagery/i.atcorr/create_iwave.py: F632, F821, W293
doc/python/raster_example_ctypes.py: F403, F405
doc/python/vector_example_ctypes.py: F403, F405
doc/python/m.distance.py: F403, F405, E501
doc/gui/wxpython/example/dialogs.py: F401
doc/gui/wxpython/example/g.gui.example.py: E501
locale/grass_po_stats.py: E122, E128, E231, E401, E501, E722, E741
gui/scripts/d.rast3d.py: E501
locale/grass_po_stats.py: E122, E128, E231, E401, E722, E741
gui/scripts/d.wms.py: E501
gui/wxpython/core/debug.py: E501
gui/wxpython/core/gcmd.py: E402, E501
gui/wxpython/core/giface.py: E501
gui/wxpython/core/gcmd.py: E402
gui/wxpython/core/gthread.py: F841
gui/wxpython/core/gconsole.py: E722, W605
gui/wxpython/core/globalvar.py: W605
gui/wxpython/core/toolboxes.py: E722, E501
gui/wxpython/core/toolboxes.py: E722
gui/wxpython/core/utils.py: E722, F841, W605
gui/wxpython/core/workspace.py: E722, E501
gui/wxpython/core/render.py: E722, F841, E501
gui/wxpython/core/ws.py: F841, E501
gui/wxpython/core/workspace.py: E722
gui/wxpython/core/render.py: E722, F841
gui/wxpython/core/ws.py: F841
gui/wxpython/core/settings.py: E722
gui/wxpython/core/watchdog.py: E402
gui/wxpython/datacatalog/tree.py: E731, E402, E501
gui/wxpython/dbmgr/base.py: E501, E722, F841
gui/wxpython/dbmgr/dialogs.py: E501, F841, E722
gui/wxpython/dbmgr/sqlbuilder.py: E501, E722, F841
gui/wxpython/dbmgr/manager.py: E501, E722
gui/wxpython/datacatalog/tree.py: E731, E402
gui/wxpython/dbmgr/base.py: E722, F841
gui/wxpython/dbmgr/dialogs.py: F841, E722
gui/wxpython/dbmgr/sqlbuilder.py: E722, F841
gui/wxpython/dbmgr/manager.py: E722
gui/wxpython/dbmgr/vinfo.py: F841
gui/wxpython/docs/wxgui_sphinx/conf.py: E402, E501
gui/wxpython/docs/wxgui_sphinx/conf.py: E402, W291
gui/wxpython/gcp/g.gui.gcp.py: F841
gui/wxpython/gcp/manager.py: E501, F841, E722
gui/wxpython/gcp/manager.py: F841, E722
gui/wxpython/gcp/mapdisplay.py: F841
gui/wxpython/gmodeler/*: E501
gui/wxpython/gui_core/*: F841, E266, E722, W605
gui/wxpython/gui_core/dialogs.py: E501, E722, F841, W605
gui/wxpython/gui_core/forms.py: E501, E722, F841
gui/wxpython/gui_core/ghelp.py: E501, E722
gui/wxpython/gui_core/gselect.py: E501, F841, E266, E722
gui/wxpython/gui_core/preferences.py: E501, E266, F841
gui/wxpython/gui_core/treeview.py: E501, F841
gui/wxpython/gui_core/widgets.py: E501, F841, E722, E266
gui/wxpython/image2target/*: F841, E722, E265, E501
gui/wxpython/iscatt/*: F841, E722, E741, F405, F403, E501
gui/wxpython/lmgr/giface.py: E501, E741
gui/wxpython/lmgr/frame.py: F841, E722, W605, E501
gui/wxpython/gui_core/dialogs.py: E722, F841, W605
gui/wxpython/gui_core/forms.py: E722, F841
gui/wxpython/gui_core/ghelp.py: E722
gui/wxpython/gui_core/gselect.py: F841, E266, E722
gui/wxpython/gui_core/preferences.py: E266, F841
gui/wxpython/gui_core/treeview.py: F841
gui/wxpython/gui_core/widgets.py: F841, E722, E266
gui/wxpython/image2target/*: F841, E722, E265
gui/wxpython/image2target/g.gui.image2target.py: E501, E265, F841
gui/wxpython/iscatt/*: F841, E722, E741, F405, F403
gui/wxpython/lmgr/giface.py: E741
gui/wxpython/lmgr/frame.py: F841, E722, W605
# layertree still includes some formatting issues (it is ignored by Black)
gui/wxpython/lmgr/layertree.py: E722, E266, W504, E225, E501
gui/wxpython/lmgr/layertree.py: E722, E266, W504, E225
gui/wxpython/lmgr/workspace.py: F841
gui/wxpython/modules/*: F841, E722, W605, E501
gui/wxpython/nviz/*: F841, E266, E722, W605, F403, F405, E501
gui/wxpython/photo2image/*: F841, E722, E265, E501
gui/wxpython/psmap/*: F841, E266, E722, F405, F403, E501
gui/wxpython/vdigit/*: F841, E722, E741, F405, F403, E501
gui/wxpython/vnet/*: F841, E501
gui/wxpython/modules/*: F841, E722, W605
gui/wxpython/nviz/*: F841, E266, E722, W605, F403, F405
gui/wxpython/photo2image/*: F841, E722, E265
gui/wxpython/photo2image/g.gui.photo2image.py: E501, F841
gui/wxpython/psmap/*: F841, E266, E722, F405, F403
gui/wxpython/vdigit/*: F841, E722, E741, F405, F403
gui/wxpython/vnet/*: F841
gui/wxpython/wxgui.py: F841
gui/wxpython/animation/g.gui.animation.py: E501
gui/wxpython/animation/mapwindow.py: F841
gui/wxpython/animation/provider.py: F841, E501
gui/wxpython/animation/temporal_manager.py: E501
gui/wxpython/tplot/frame.py: F841, E722
gui/wxpython/animation/provider.py: F841
gui/wxpython/tplot/frame.py: F841, E722, E741
gui/wxpython/tplot/g.gui.tplot.py: E501
gui/wxpython/rdigit/g.gui.rdigit.py: F841
gui/wxpython/rdigit/toolbars.py: E501
gui/wxpython/iclass/dialogs.py: E741, E501
gui/wxpython/iclass/dialogs.py: E741
gui/wxpython/iclass/digit.py: F405, F403
gui/wxpython/iclass/frame.py: F405, F403, E501
gui/wxpython/iclass/frame.py: F405, F403
gui/wxpython/iclass/g.gui.iclass.py: E501
gui/wxpython/iclass/statistics.py: F841, F405, F403
gui/wxpython/wxplot/dialogs.py: E501
gui/wxpython/wxplot/histogram.py: E722
gui/wxpython/wxplot/profile.py: F841, E722
gui/wxpython/wxplot/base.py: F841, E722
gui/wxpython/wxplot/scatter.py: E501
gui/wxpython/location_wizard/dialogs.py: F841, E501
gui/wxpython/location_wizard/dialogs.py: F841
gui/wxpython/location_wizard/wizard.py: E722
gui/wxpython/mapdisp/frame.py: E501
gui/wxpython/mapdisp/main.py: E722, E501
gui/wxpython/mapdisp/main.py: E722
gui/wxpython/mapdisp/test_mapdisp.py: E501
gui/wxpython/mapdisp/toolbars.py: E501
gui/wxpython/mapdisp/statusbar.py: F841, E501
gui/wxpython/mapdisp/statusbar.py: F841
gui/wxpython/mapswipe/g.gui.mapswipe.py: E501
gui/wxpython/mapwin/base.py: E722, E501
gui/wxpython/mapwin/buffered.py: E722, E501
gui/wxpython/mapwin/decorations.py: E501
gui/wxpython/mapwin/base.py: E722
gui/wxpython/mapwin/buffered.py: E722
gui/wxpython/mapwin/graphics.py: E722
gui/wxpython/startup/locdownload.py: E722, E402, E501
gui/wxpython/timeline/g.gui.timeline.py: E501
gui/wxpython/tools/build_modules_xml.py: E722, E501
gui/wxpython/startup/locdownload.py: E722, E402
gui/wxpython/timeline/g.gui.timeline.py: E501, E741
gui/wxpython/timeline/frame.py: E741
gui/wxpython/tools/build_modules_xml.py: E722
gui/wxpython/web_services/cap_interface.py: E501
gui/wxpython/web_services/dialogs.py: E501
gui/wxpython/web_services/widgets.py: F841, E741, W605, E402, E501
gui/wxpython/web_services/widgets.py: F841, E741, W605, E402
gui/wxpython/rlisetup/frame.py: E741
gui/wxpython/rlisetup/sampling_frame.py: F841
gui/wxpython/rlisetup/wizard.py: E722, E741
Expand All @@ -138,85 +127,69 @@ per-file-ignores =
python/grass/pydispatch/saferef.py: F821
# C wrappers call libgis.G_gisinit before importing other modules.
# TODO: Is this really needed?
python/grass/pygrass/vector/__init__.py: E402,
python/grass/pygrass/raster/__init__.py: E402,
python/grass/gunittest/*.py: E501 # These are mainly just todo comments
python/grass/gunittest/gmodules.py: E501, W605
python/grass/pygrass/vector/__init__.py: E402
python/grass/pygrass/raster/__init__.py: E402
python/grass/gunittest/gmodules.py: W605
python/grass/gunittest/invoker.py: E721
python/grass/pygrass/vector/geometry.py: W605
python/grass/pygrass/vector/table.py: E501
python/grass/pygrass/vector/__init__.py: E501, E402
python/grass/pygrass/modules/interface/*.py: E501, F401
python/grass/pygrass/modules/interface/module.py: E501, W605
python/grass/pygrass/modules/interface/parameter.py: E501, W605
python/grass/pygrass/modules/grid/*.py: E501, F401
python/grass/pygrass/raster/*.py: E501
python/grass/pygrass/vector/__init__.py: E402
python/grass/pygrass/modules/interface/*.py: F401
python/grass/pygrass/modules/interface/module.py: W605
python/grass/pygrass/modules/interface/parameter.py: W605
python/grass/pygrass/modules/grid/*.py: F401
python/grass/pygrass/raster/rowio.py: E741
python/grass/pygrass/rpc/__init__.py: E501, F401, F403
python/grass/pygrass/utils.py: E402, E501
python/grass/script/db.py: E501
python/grass/pygrass/raster/category.py: E721
python/grass/pygrass/rpc/__init__.py: F401, F403
python/grass/pygrass/utils.py: E402
python/grass/script/task.py: W605
python/grass/script/vector.py: E501 # Long doctest lines which need review anyway
python/grass/temporal/abstract_map_dataset.py: E501
python/grass/temporal/abstract_space_time_dataset.py: W605, E501, F841, E722
python/grass/temporal/aggregation.py: E501
python/grass/temporal/base.py: E501
python/grass/temporal/c_libraries_interface.py: E501, F841, E722
python/grass/temporal/core.py: E501, E722
python/grass/temporal/datetime_math.py: E501, F841, E722
python/grass/temporal/list_stds.py: E501
python/grass/temporal/metadata.py: E501
python/grass/temporal/abstract_space_time_dataset.py: W605, F841, E722
python/grass/temporal/c_libraries_interface.py: F841, E722
python/grass/temporal/core.py: E722
python/grass/temporal/datetime_math.py: F841, E722
python/grass/temporal/open_stds.py: F841
python/grass/temporal/register.py: E501
python/grass/temporal/space_time_datasets.py: E501
python/grass/temporal/spatial_extent.py: E501
python/grass/temporal/spatial_topology_dataset_connector.py: E501, E722
python/grass/temporal/spatio_temporal_relationships.py: E501
python/grass/temporal/temporal_algebra.py: E741, E501, F841, E722
python/grass/temporal/temporal_extent.py: E501
python/grass/temporal/temporal_granularity.py: E501, F841, E722
python/grass/temporal/temporal_operator.py: E501
python/grass/temporal/spatial_topology_dataset_connector.py: E722
python/grass/temporal/temporal_algebra.py: E741, F841, E722
python/grass/temporal/temporal_granularity.py: F841, E722
python/grass/temporal/temporal_raster_algebra.py: E741
python/grass/temporal/temporal_raster_base_algebra.py: E501, F841, E722
python/grass/temporal/temporal_raster_base_algebra.py: F841, E722
python/grass/temporal/temporal_raster3d_algebra.py: E741
python/grass/temporal/temporal_topology_dataset_connector.py: E501, E722
python/grass/temporal/temporal_vector_algebra.py: E741, E501, F841
python/grass/temporal/univar_statistics.py: E501
python/grass/temporal/temporal_topology_dataset_connector.py: E722
python/grass/temporal/temporal_vector_algebra.py: E741, F841
python/grass/temporal/univar_statistics.py: E231
# Current benchmarks/tests are changing sys.path before import.
# Possibly, a different approach should be taken there anyway.
python/grass/pygrass/tests/benchmark.py: E501, E402, F401, F821
python/grass/pygrass/tests/benchmark.py: E402, F401, F821
# Configuration file for Sphinx:
# Ignoring import/code mix and line length.
python/grass/docs/conf.py: E402, E501,
python/grass/docs/conf.py: E402
# Files not managed by Black
python/grass/imaging/images2gif.py: E226, E501
python/grass/imaging/images2gif.py: E226
# Unused imports in init files
# F401 imported but unused
# F403 star import used; unable to detect undefined names
python/grass/*/__init__.py: F401, F403
python/grass/*/*/__init__.py: F401, F403
python/grass/*/*/*/__init__.py: F401, F403
# E402 module level import not at top of file
scripts/d.polar/d.polar.py: F841, E501
scripts/r.in.wms/wms_gdal_drv.py: F841, E722, E501
scripts/r.in.wms/wms_cap_parsers.py: F841, E741, E501
scripts/r.in.wms/wms_drv.py: E402, E722, E501
scripts/r.in.wms/srs.py: E722, E501
scripts/d.polar/d.polar.py: F841
scripts/r.in.wms/wms_gdal_drv.py: F841, E722
scripts/r.in.wms/wms_cap_parsers.py: F841, E741
scripts/r.in.wms/wms_drv.py: E402, E722
scripts/r.in.wms/srs.py: E722
scripts/r.semantic.label/r.semantic.label.py: F841, E501
scripts/v.report/v.report.py: F841, E501
scripts/v.report/v.report.py: F841, E721
scripts/db.out.ogr/db.out.ogr.py: F841
scripts/g.extension/g.extension.py: F841, E722, E501
scripts/r.unpack/r.unpack.py: E501
scripts/v.unpack/v.unpack.py: F841, E722, E501
scripts/v.import/v.import.py: F841, E722, E501
scripts/db.univar/db.univar.py: E741, E501
scripts/d.rast.leg/d.rast.leg.py: E741
scripts/d.frame/d.frame.py: E722, E501
scripts/d.frame/d.frame.py: E722
scripts/i.pansharpen/i.pansharpen.py: E722, E501
scripts/r.in.srtm/r.in.srtm.py: E722, E501
scripts/r.fillnulls/r.fillnulls.py: E722, E501
scripts/d.rast.edit/d.rast.edit.py: E722, E501
scripts/r.in.srtm/r.in.srtm.py: E722
scripts/r.fillnulls/r.fillnulls.py: E722
scripts/d.rast.edit/d.rast.edit.py: E722
scripts/v.what.strds/v.what.strds.py: E722, E501
scripts/i.in.spotvgt/i.in.spotvgt.py: E501
# Line too long (esp. module interface definitions)
scripts/*/*.py: E501
# local variable 'column' is assigned to but never used
Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/animation/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ def SetCmds(self, cmdsForComposition, opacities, regions=None):
Applies to 2D mode.
:param cmdsForComposition: list of lists of command lists
[[['d.rast', 'map=elev_2001'], ['d.vect', 'map=points']], # g.pnmcomp
[['d.rast', 'map=elev_2002'], ['d.vect', 'map=points']],
...]
[[['d.rast', 'map=elev_2001'], ['d.vect', 'map=points']], # g.pnmcomp
[['d.rast', 'map=elev_2002'], ['d.vect', 'map=points']],
...]
:param opacities: list of opacity values
:param regions: list of regions
"""
Expand Down
3 changes: 2 additions & 1 deletion gui/wxpython/animation/temporal_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def _setTemporalState(self):
message = _(
"You are going to display data with different "
"temporal types of maps (interval and point)."
" It is recommended to use data of one temporal type to avoid confusion."
" It is recommended to use data of one temporal type to avoid "
"confusion."
)
return True, message # warning

Expand Down
5 changes: 3 additions & 2 deletions gui/wxpython/core/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ def SetLevel(self):
self.debuglevel = 0
sys.stderr.write(
_(
"WARNING: Ignoring unsupported wx debug level (must be >=0 and <=5). {0}\n"
).format(e)
"WARNING: Ignoring unsupported wx debug level (must be >=0 and "
"<=5). {0}\n".format(e)
)
)

def msg(self, level, message, *args):
Expand Down
3 changes: 2 additions & 1 deletion gui/wxpython/core/gcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,8 @@ def RunCommand(
:param env: environment (optional, uses os.environ if not provided)
:param kwargs: program parameters
The environment passed to the function (env or os.environ) is not modified (a copy is used internally).
The environment passed to the function (env or os.environ) is not modified
(a copy is used internally).
:return: returncode (read == False and getErrorMsg == False)
:return: returncode, messages (read == False and getErrorMsg == True)
Expand Down
6 changes: 4 additions & 2 deletions gui/wxpython/core/giface.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,12 @@ def __init__(self):
# Signal for communicating something in current grassdb has changed.
# Parameters:
# action: required, is one of 'new', 'rename', 'delete'
# element: required, can be one of 'grassdb', 'location', 'mapset', 'raster', 'vector' and 'raster_3d'
# element: required, can be one of 'grassdb', 'location', 'mapset', 'raster',
# 'vector' and 'raster_3d'
# grassdb: path to grass db, required
# location: location name, required
# mapset: mapset name, required when element is 'mapset', 'raster', 'vector' or 'raster_3d'
# mapset: mapset name, required when element is 'mapset', 'raster',
# 'vector' or 'raster_3d'
# map: map name, required when element is 'raster', 'vector' or 'raster_3d'
# newname: new name (of mapset, map), required with action='rename'
self.grassdbChanged = Signal("StandaloneGrassInterface.grassdbChanged")
Expand Down
6 changes: 4 additions & 2 deletions gui/wxpython/core/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,8 @@ def GetRegion(
:param rast: list of raster maps
:param zoom: zoom to raster map (ignore NULLs)
:param vect: list of vector maps
:param rast3d: 3d raster map (not list, no support of multiple 3d rasters in g.region)
:param rast3d: 3d raster map (not list, no support of multiple 3d rasters in
g.region)
:param regionName: named region or None
:param n,s,e,w: force extent
:param default: force default region settings
Expand Down Expand Up @@ -1256,7 +1257,8 @@ def GetListOfLayers(
"""Returns list of layers of selected properties or list of
all layers.
:param ltype: layer type, e.g. raster/vector/wms/overlay (value or tuple of values)
:param ltype: layer type, e.g. raster/vector/wms/overlay (value or tuple of
values)
:param mapset: all layers from given mapset (only for maplayers)
:param name: all layers with given name
:param active: only layers with 'active' attribute set to True or False
Expand Down
Loading

0 comments on commit 763fa05

Please sign in to comment.