Skip to content

Commit

Permalink
style: Fix pylint pointless-statement (W0104) (#3996)
Browse files Browse the repository at this point in the history
* temporal: Actually call dbif.close() to fix pylint pointless-statement (W0104)

* g.extension: Fix pylint pointless-statement (W0104)

* temporal: Fix pointless-statement (W0104) in temporal_granularity

* temporal: Fix pointless-statement (W0104) in c_libraries_interface.py, _read_vector_history() function

* i.atcorr: Remove useless and non-working print statements in create_iwave.py

* python(grass.imaging): Use PIL.__version__ call to fix pylint pointless-statement

* style: Ignore ruff useless-expression (B018) for a gunittest data file. Equivalent to pylint pointless-statement / W010

* style: Enable ruff useless-expression (B018) (equivalent to pylint pointless-statement / W010)
  • Loading branch information
echoix committed Jul 8, 2024
1 parent c94708a commit cd64472
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 20 deletions.
8 changes: 0 additions & 8 deletions imagery/i.atcorr/create_iwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,15 @@
def usage():
"""How to use this..."""
print("create_iwave.py <csv file>")
print
print("Generates filter function template for iwave.cpp from csv file. Note:")
print("- csv file must have wl response for each band in each column")
print("- first line must be a header with wl followed by band names")
print("- all following lines will be the data.")
print("If spectral response is null, leave field empty in csv file. Example:")
print
print("WL(nm),band 1,band 2,band 3,band 4")
print("455,0.93,,,")
print("485,0.94,0.00,,")
print("545,0.00,0.87,0.00,")
print
print("This script will interpolate the filter functions to 2.5 nm steps")
print("and output a cpp template file in the IWave format to be added to iwave.cpp")

Expand Down Expand Up @@ -207,7 +204,6 @@ def write_cpp(bands, values, sensor, folder):

# keep in sync with IWave::parse()
rthresh = 0.01
print
print(" > Response peaks from interpolation to 2.5 nm steps:")

# getting necessary data
Expand Down Expand Up @@ -334,7 +330,6 @@ def main():
# getting sensor name from full csv file name
sensor = os.path.splitext(os.path.basename(inputfile))[0]

print
print(" > Getting sensor name from csv file: %s" % (sensor))

# getting data from file
Expand All @@ -344,7 +339,6 @@ def main():
# consider only wavelengths with a reasonably large response
# around the peak response, keep in sync with IWave::parse()
rthresh = 0.01
print
print(" > Response peaks from input file:")
for b in range(1, len(bands) + 1):
lowl = 0
Expand Down Expand Up @@ -372,7 +366,6 @@ def main():
# writing file in same folder of input file
write_cpp(bands, values, sensor, os.path.dirname(inputfile))

print
print(
" > Filter functions exported to %s"
% ("sensors_csv/" + sensor + "_cpp_template.txt")
Expand All @@ -385,7 +378,6 @@ def main():
" > Don't forget to add the necessary data to the files"
" iwave.h, geomcond.h, geomcond.cpp, and to i.atcorr.html"
)
print


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ ignore = [
"B008", # function-call-in-default-argument
"B009", # get-attr-with-constant
"B015", # useless-comparison
"B018", # useless-expression
"B020", # loop-variable-overrides-iterator
"B023", # function-uses-loop-variable
"B026", # star-arg-unpacking-after-keyword-arg
Expand Down Expand Up @@ -388,6 +387,7 @@ ignore = [
"python/grass/__init__.py" = ["PYI056"]
"python/grass/gunittest/loader.py" = ["PYI024"]
"python/grass/gunittest/multireport.py" = ["PYI024"]
"python/grass/gunittest/testsu*/d*/s*/s*/subsub*/t*/test_segfaut.py" = ["B018"]
"python/grass/gunittest/testsuite/test_assertions_rast3d.py" = ["FLY002"]
"python/grass/jupyter/tests/reprojection_renderer_test.py" = ["PT013"]
"python/grass/jupyter/testsuite/interactivemap_test.py" = ["PGH004"]
Expand Down
2 changes: 1 addition & 1 deletion python/grass/imaging/images2gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

pillow = True
try:
PIL.__version__ # test if user has Pillow or PIL
PIL_version = PIL.__version__ # test if user has Pillow or PIL
except AttributeError:
pillow = False
from PIL.GifImagePlugin import getheader, getdata
Expand Down
12 changes: 6 additions & 6 deletions python/grass/temporal/abstract_map_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ def get_registered_stds(self, dbif=None, mapset=None):
datasets = None

if connection_state_changed:
dbif.close
dbif.close()

return datasets

Expand Down Expand Up @@ -1168,7 +1168,7 @@ def add_stds_to_register(self, stds_id, dbif=None, execute=True):
# Check if the dataset is already present
if stds_id in datasets:
if connection_state_changed:
dbif.close
dbif.close()
return ""

datasets.append(stds_id)
Expand All @@ -1183,7 +1183,7 @@ def add_stds_to_register(self, stds_id, dbif=None, execute=True):
statement = self.stds_register.get_update_statement_mogrified(dbif=dbif)

if connection_state_changed:
dbif.close
dbif.close()

return statement

Expand All @@ -1210,13 +1210,13 @@ def remove_stds_from_register(self, stds_id, dbif=None, execute=True):
# Check if no datasets are present
if datasets is None:
if connection_state_changed:
dbif.close
dbif.close()
return ""

# Check if the dataset is already present
if stds_id not in datasets:
if connection_state_changed:
dbif.close
dbif.close()
return ""

datasets.remove(stds_id)
Expand All @@ -1231,7 +1231,7 @@ def remove_stds_from_register(self, stds_id, dbif=None, execute=True):
statement = self.stds_register.get_update_statement_mogrified(dbif=dbif)

if connection_state_changed:
dbif.close
dbif.close()

return statement

Expand Down
2 changes: 1 addition & 1 deletion python/grass/temporal/c_libraries_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ def _read_vector_history(name, mapset):
kvp["creation_time"] = decode(libvector.Vect_get_map_date(byref(Map)))
kvp["creator"] = decode(libvector.Vect_get_person(byref(Map)))
else:
None
kvp = None
libvector.Vect_close(byref(Map))

return kvp
Expand Down
1 change: 0 additions & 1 deletion python/grass/temporal/temporal_granularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def check_granularity_string(granularity, temporal_type):
False
"""
temporal_type

if granularity is None:
return False
Expand Down
3 changes: 1 addition & 2 deletions scripts/g.extension/g.extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -2600,8 +2600,7 @@ def resolve_known_host_service(url, name, branch):
url = "{prefix}{base}{suffix}".format(
prefix=actual_start, base=url.rstrip("/"), suffix=suffix
)
gs.verbose
(_("Will use the following URL for download: {0}").format(url))
gs.verbose(_("Will use the following URL for download: {0}").format(url))
return "remote_zip", url
else:
return None, None
Expand Down

0 comments on commit cd64472

Please sign in to comment.