Skip to content

Commit

Permalink
style: Enable checking for E ruff rules from pycodestyle, fixing simp…
Browse files Browse the repository at this point in the history
…le 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
  • Loading branch information
echoix authored Oct 20, 2024
1 parent 32723e0 commit e523163
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 38 deletions.
2 changes: 1 addition & 1 deletion gui/wxpython/psmap/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 0 additions & 4 deletions gui/wxpython/psmap/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
8 changes: 3 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions python/grass/temporal/univar_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
]
)
Expand Down
4 changes: 2 additions & 2 deletions raster/r.basins.fill/testsuite/testrbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions raster/r.in.ascii/testsuite/test_r_in_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions raster/r.proj/testsuite/test_rproj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions raster/r.reclass/testsuite/test_r_reclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions raster/r.tile/testsuite/testrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions raster/r.what/testsuite/testrw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/r.reclass.area/testsuite/testrra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions vector/v.extract/testsuite/test_v_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions vector/v.vect.stats/testsuite/test_vect_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e523163

Please sign in to comment.