From e523163b16c24df62d23c7e5bf149846ae2d42d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 20 Oct 2024 16:02:11 -0400 Subject: [PATCH] style: Enable checking for E ruff rules from pycodestyle, fixing simple issues (#4560) * style: Fix missing-whitespace (E231) * style: Fix mixed-spaces-and-tabs (E101) Ruff rule: https://docs.astral.sh/ruff/rules/mixed-spaces-and-tabs/ * style: Enable checking for E ruff rules from pycodestyle * style: Fix multiple-leading-hashes-for-block-comment (E266) Ruff rule: https://docs.astral.sh/ruff/rules/multiple-leading-hashes-for-block-comment/ For gui/wxpython/psmap/frame.py, the commented code was present since it was moved from addons to the main repo 13 years ago. At the time, both pair of lines had the same indentation, before PEP8 only formatted the second lines. File temporal/t.rast.what/t.rast.what.py is ignored for E265 and E266, as it is being addressed in #4550 --- gui/wxpython/psmap/dialogs.py | 2 +- gui/wxpython/psmap/frame.py | 4 ---- pyproject.toml | 8 +++----- python/grass/temporal/univar_statistics.py | 4 ++-- raster/r.basins.fill/testsuite/testrbf.py | 4 ++-- .../r.in.ascii/testsuite/test_r_in_ascii.py | 4 ++-- raster/r.proj/testsuite/test_rproj.py | 20 +++++++++---------- raster/r.reclass/testsuite/test_r_reclass.py | 4 ++-- raster/r.tile/testsuite/testrt.py | 4 ++-- raster/r.what/testsuite/testrw.py | 4 ++-- scripts/r.reclass.area/testsuite/testrra.py | 4 ++-- vector/v.extract/testsuite/test_v_extract.py | 4 ++-- .../v.vect.stats/testsuite/test_vect_stats.py | 4 ++-- 13 files changed, 32 insertions(+), 38 deletions(-) diff --git a/gui/wxpython/psmap/dialogs.py b/gui/wxpython/psmap/dialogs.py index 0bbe779818a..c4784525cc9 100644 --- a/gui/wxpython/psmap/dialogs.py +++ b/gui/wxpython/psmap/dialogs.py @@ -3619,7 +3619,7 @@ def _rasterLegend(self, notebook): self.Bind(wx.EVT_CHECKBOX, self.OnIsLegend, self.isRLegend) self.Bind(wx.EVT_RADIOBUTTON, self.OnDiscrete, self.discrete) self.Bind(wx.EVT_RADIOBUTTON, self.OnDiscrete, self.continuous) - ## self.Bind(wx.EVT_CHECKBOX, self.OnDefaultSize, panel.defaultSize) + # self.Bind(wx.EVT_CHECKBOX, self.OnDefaultSize, panel.defaultSize) self.Bind(wx.EVT_CHECKBOX, self.OnRange, self.range) self.rasterSelect.GetTextCtrl().Bind(wx.EVT_TEXT, self.OnRaster) diff --git a/gui/wxpython/psmap/frame.py b/gui/wxpython/psmap/frame.py index 13fdc91a984..1d937483123 100644 --- a/gui/wxpython/psmap/frame.py +++ b/gui/wxpython/psmap/frame.py @@ -780,8 +780,6 @@ def OnAddRaster(self, event): if not self._checkMapFrameExists(type_id=id): return - ## dlg = RasterDialog(self, id = id, settings = self.instruction) - # dlg.ShowModal() if "mapNotebook" in self.openDialogs: self.openDialogs["mapNotebook"].notebook.ChangeSelection(1) else: @@ -800,8 +798,6 @@ def OnAddVect(self, event): if not self._checkMapFrameExists(type_id=id): return - ## dlg = MainVectorDialog(self, id = id, settings = self.instruction) - # dlg.ShowModal() if "mapNotebook" in self.openDialogs: self.openDialogs["mapNotebook"].notebook.ChangeSelection(2) else: diff --git a/pyproject.toml b/pyproject.toml index eeffbc0ec95..4b7856bab3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,9 +34,7 @@ select = [ "COM", # flake8-commas (COM) "D", # pydocstyle (D) "DTZ", # flake8-datetimez (DTZ) - "E4", # pycodestyle (E, W) - "E7", # pycodestyle (E, W) - "E9", # pycodestyle (E, W) + "E", # pycodestyle (E, W) "F", # Pyflakes (F) "FA", # flake8-future-annotations (FA) "FBT", # flake8-boolean-trap (FBT) @@ -127,8 +125,8 @@ ignore = [ "DTZ006", # call-datetime-fromtimestamp "DTZ007", # call-datetime-strptime-without-zone "DTZ011", # call-date-today - "E401", # multiple-imports-on-one-line "E402", # module-import-not-at-top-of-file + "E501", # line-too-long "E721", # type-comparison "E722", # bare-except "E731", # lambda-assignment @@ -366,7 +364,7 @@ ignore = [ "temporal/t.rast.algebra/testsu*/*_algebra_arithmetic.py" = ["FLY002"] "temporal/t.rast.colors/t.rast.colors.py" = ["SIM115"] "temporal/t.rast.series/t.rast.series.py" = ["SIM115"] -"temporal/t.rast.what/t.rast.what.py" = ["SIM115"] +"temporal/t.rast.what/t.rast.what.py" = ["E265", "E266", "SIM115"] "temporal/t.register/testsu*/*_raster_different_local.py" = ["FLY002"] "temporal/t.register/testsu*/*_raster_mapmetadata.py" = ["FLY002"] "temporal/t.register/testsuite/test_t_register_raster.py" = ["FLY002"] diff --git a/python/grass/temporal/univar_statistics.py b/python/grass/temporal/univar_statistics.py index 96a9f65474d..dd334e7e9f1 100755 --- a/python/grass/temporal/univar_statistics.py +++ b/python/grass/temporal/univar_statistics.py @@ -103,7 +103,7 @@ def compute_univar_stats(registered_map_info, stats_module, fs, rast_region=Fals for perc in stats_module.inputs.percentile: perc_value = stats[ "percentile_" - f"{str(perc).rstrip('0').rstrip('.').replace('.','_')}" + f"{str(perc).rstrip('0').rstrip('.').replace('.', '_')}" ] string += f"{fs}{perc_value}" string += eol @@ -220,7 +220,7 @@ def print_gridded_dataset_univar_statistics( cols.extend( [ "percentile_" - f"{str(perc).rstrip('0').rstrip('.').replace('.','_')}" + f"{str(perc).rstrip('0').rstrip('.').replace('.', '_')}" for perc in percentile ] ) diff --git a/raster/r.basins.fill/testsuite/testrbf.py b/raster/r.basins.fill/testsuite/testrbf.py index eaa57388150..4077a2113a4 100644 --- a/raster/r.basins.fill/testsuite/testrbf.py +++ b/raster/r.basins.fill/testsuite/testrbf.py @@ -5,8 +5,8 @@ Author: Sunveer Singh Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ import unittest diff --git a/raster/r.in.ascii/testsuite/test_r_in_ascii.py b/raster/r.in.ascii/testsuite/test_r_in_ascii.py index cff31b7b3e2..baa892d83a8 100644 --- a/raster/r.in.ascii/testsuite/test_r_in_ascii.py +++ b/raster/r.in.ascii/testsuite/test_r_in_ascii.py @@ -5,8 +5,8 @@ Author: Sunveer Singh, Google Code-in 2017 Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ from grass.gunittest.case import TestCase diff --git a/raster/r.proj/testsuite/test_rproj.py b/raster/r.proj/testsuite/test_rproj.py index 5f3834be881..678e8b7cd06 100644 --- a/raster/r.proj/testsuite/test_rproj.py +++ b/raster/r.proj/testsuite/test_rproj.py @@ -57,7 +57,7 @@ def run_rproj_test(self, method, statics): The expected statics of the output raster """ output = method - ## Get the boundary and set up region for the projected map + # Get the boundary and set up region for the projected map stdout = call_module( "r.proj", project=src_project, @@ -80,7 +80,7 @@ def run_rproj_test(self, method, statics): res=1, ) - ## Project the map + # Project the map self.assertModule( "r.proj", project=src_project, @@ -91,13 +91,13 @@ def run_rproj_test(self, method, statics): quiet=True, ) - ## Validate the output + # Validate the output self.assertRasterFitsUnivar(output, reference=statics, precision=1e-7) self.assertRasterFitsInfo(output, reference=raster_info, precision=1e-7) def test_nearest(self): """Testing method nearest""" - ## Set up variables and validation values + # Set up variables and validation values method = "nearest" statics = """n=40930 min=55.5787925720215 @@ -109,7 +109,7 @@ def test_nearest(self): def test_bilinear(self): """Testing method bilinear""" - ## Set up variables and validation values + # Set up variables and validation values method = "bilinear" statics = """n=40845 min=56.3932914733887 @@ -121,7 +121,7 @@ def test_bilinear(self): def test_bicubic(self): """Testing method bicubic""" - ## Set up variables and validation values + # Set up variables and validation values method = "bicubic" statics = """n=40677 min=56.2407836914062 @@ -133,7 +133,7 @@ def test_bicubic(self): def test_lanczos(self): """Testing method lanczos""" - ## Set up variables and validation values + # Set up variables and validation values method = "lanczos" statics = """n=40585 min=56.2350921630859 @@ -145,7 +145,7 @@ def test_lanczos(self): def test_bilinear_f(self): """Testing method bilinear_f""" - ## Set up variables and validation values + # Set up variables and validation values method = "bilinear_f" statics = """n=40930 min=55.5787925720215 @@ -157,7 +157,7 @@ def test_bilinear_f(self): def test_bicubic_f(self): """Testing method bicubic_f""" - ## Set up variables and validation values + # Set up variables and validation values method = "bicubic_f" statics = """n=40930 min=55.5787925720215 @@ -169,7 +169,7 @@ def test_bicubic_f(self): def test_lanczos_f(self): """Testing method lanczos_f""" - ## Set up variables and validation values + # Set up variables and validation values method = "lanczos_f" statics = """n=40930 min=55.5787925720215 diff --git a/raster/r.reclass/testsuite/test_r_reclass.py b/raster/r.reclass/testsuite/test_r_reclass.py index 3f4ecfdf6a3..8b1eb2e523a 100644 --- a/raster/r.reclass/testsuite/test_r_reclass.py +++ b/raster/r.reclass/testsuite/test_r_reclass.py @@ -5,8 +5,8 @@ Author: Sunveer Singh, Google Code-in 2017 Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ from grass.gunittest.case import TestCase diff --git a/raster/r.tile/testsuite/testrt.py b/raster/r.tile/testsuite/testrt.py index 6cb5a91c296..a26ff967d33 100644 --- a/raster/r.tile/testsuite/testrt.py +++ b/raster/r.tile/testsuite/testrt.py @@ -5,8 +5,8 @@ Author: Sunveer Singh, Google Code-in 2018 Copyright: (C) 2018 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ from grass.gunittest.case import TestCase diff --git a/raster/r.what/testsuite/testrw.py b/raster/r.what/testsuite/testrw.py index 8184f534720..fdaf7eec98c 100644 --- a/raster/r.what/testsuite/testrw.py +++ b/raster/r.what/testsuite/testrw.py @@ -5,8 +5,8 @@ Author: Sunveer Singh, Google Code-in 2018 Copyright: (C) 2018 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ from grass.gunittest.case import TestCase diff --git a/scripts/r.reclass.area/testsuite/testrra.py b/scripts/r.reclass.area/testsuite/testrra.py index 8270c122129..5e11bf6aecc 100644 --- a/scripts/r.reclass.area/testsuite/testrra.py +++ b/scripts/r.reclass.area/testsuite/testrra.py @@ -5,8 +5,8 @@ Author: Sunveer Singh, Google Code-in 2018 Copyright: (C) 2018 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ from grass.gunittest.case import TestCase diff --git a/vector/v.extract/testsuite/test_v_extract.py b/vector/v.extract/testsuite/test_v_extract.py index 7f067c5723e..958f153d1a3 100644 --- a/vector/v.extract/testsuite/test_v_extract.py +++ b/vector/v.extract/testsuite/test_v_extract.py @@ -5,8 +5,8 @@ Author: Sunveer Singh, Google Code-in 2017 Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ import os diff --git a/vector/v.vect.stats/testsuite/test_vect_stats.py b/vector/v.vect.stats/testsuite/test_vect_stats.py index fe982ceff33..e8a1c30c966 100644 --- a/vector/v.vect.stats/testsuite/test_vect_stats.py +++ b/vector/v.vect.stats/testsuite/test_vect_stats.py @@ -5,8 +5,8 @@ Author: Sunveer Singh, Google Code-in 2017 Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ from grass.gunittest.case import TestCase