From 78f833538b19381545fdc1de82e806d9a3c53837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Fri, 3 Jan 2025 00:17:43 +0000 Subject: [PATCH 1/8] python: Factor out lines executed in both branches --- python/grass/imaging/images2gif.py | 3 +-- python/grass/pygrass/vector/table.py | 10 +++------- python/grass/temporal/temporal_vector_algebra.py | 4 ++-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/python/grass/imaging/images2gif.py b/python/grass/imaging/images2gif.py index b3ee3062719..e738aac96bc 100644 --- a/python/grass/imaging/images2gif.py +++ b/python/grass/imaging/images2gif.py @@ -454,15 +454,14 @@ def writeGifToFile(self, fp, images, durations, loops, xys, disposes): lid = self.getImageDescriptor(im, xys[frames]) # Write local header + fp.write(graphext) if (palette != globalPalette) or (disposes[frames] != 2): # Use local color palette - fp.write(graphext) fp.write(lid) # write suitable image descriptor fp.write(palette) # write local color table fp.write("\x08") # LZW minimum size code else: # Use global color palette - fp.write(graphext) fp.write(imdes) # write suitable image descriptor # Write image data diff --git a/python/grass/pygrass/vector/table.py b/python/grass/pygrass/vector/table.py index ee972a5b634..ac52d31baad 100644 --- a/python/grass/pygrass/vector/table.py +++ b/python/grass/pygrass/vector/table.py @@ -265,9 +265,9 @@ def update_odict(self): """Read columns name and types from table and update the odict attribute. """ + cur = self.conn.cursor() if self.is_pg(): # is a postgres connection - cur = self.conn.cursor() cur.execute("SELECT oid,typname FROM pg_type") diz = dict(cur.fetchall()) odict = OrderedDict() @@ -281,17 +281,15 @@ def update_odict(self): odict[name] = diz[ctype] except pg.ProgrammingError: pass - self.odict = odict else: # is a sqlite connection - cur = self.conn.cursor() cur.execute(sql.PRAGMA.format(tname=self.tname)) descr = cur.fetchall() odict = OrderedDict() for column in descr: name, ctype = column[1:3] odict[name] = ctype - self.odict = odict + self.odict = odict values = ",".join( [ "?", @@ -363,11 +361,9 @@ def names(self, remove=None, unicod=True): ['cat', 'name', 'value'] """ + nams = list(self.odict.keys()) if remove: - nams = list(self.odict.keys()) nams.remove(remove) - else: - nams = list(self.odict.keys()) if unicod: return nams return [str(name) for name in nams] diff --git a/python/grass/temporal/temporal_vector_algebra.py b/python/grass/temporal/temporal_vector_algebra.py index 099a56b89e5..1cf981324f2 100644 --- a/python/grass/temporal/temporal_vector_algebra.py +++ b/python/grass/temporal/temporal_vector_algebra.py @@ -547,9 +547,9 @@ def p_statement_assign(self, t): ) for map_i in register_list: # Check if modules should be executed from command list. + map_i.load() if hasattr(map_i, "cmd_list") or hasattr(map_i, "is_new"): # Get meta data from grass database. - map_i.load() if map_i.is_in_db(dbif=dbif) and self.overwrite: # Update map in temporal database. map_i.update_all(dbif=dbif) @@ -568,7 +568,7 @@ def p_statement_assign(self, t): map_i.insert(dbif=dbif) else: # Map is original from an input STVDS - map_i.load() + pass # Register map in result space time dataset. if self.debug: print(map_i.get_temporal_extent_as_tuple()) From 841f29f88134457de4a5966aed69d4a813398c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Fri, 3 Jan 2025 00:30:07 +0000 Subject: [PATCH 2/8] style: Use parentheses when assigning tuples --- python/grass/imaging/images2gif.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/python/grass/imaging/images2gif.py b/python/grass/imaging/images2gif.py index e738aac96bc..8668b3c77c4 100644 --- a/python/grass/imaging/images2gif.py +++ b/python/grass/imaging/images2gif.py @@ -119,7 +119,7 @@ def checkImages(images): # Check and convert dtype if im.dtype == np.uint8: images2.append(im) # Ok - elif im.dtype in [np.float32, np.float64]: + elif im.dtype in (np.float32, np.float64): im = im.copy() im[im < 0] = 0 im[im > 1] = 1 @@ -297,7 +297,7 @@ def handleSubRectangles(self, images, subRectangles): images, xy = self.getSubRectangles(images) # Done - return images, xy + return (images, xy) def getSubRectangles(self, ims): """getSubRectangles(ims) @@ -314,7 +314,7 @@ def getSubRectangles(self, ims): # Check image count if len(ims) < 2: - return ims, [(0, 0) for i in ims] + return (ims, [(0, 0) for i in ims]) # We need NumPy if np is None: @@ -337,11 +337,11 @@ def getSubRectangles(self, ims): Y = np.argwhere(diff.sum(1)) # Get rect coordinates if X.size and Y.size: - x0, x1 = int(X[0]), int(X[-1] + 1) - y0, y1 = int(Y[0]), int(Y[-1] + 1) + x0, x1 = (int(X[0]), int(X[-1] + 1)) + y0, y1 = (int(Y[0]), int(Y[-1] + 1)) else: # No change ... make it minimal - x0, x1 = 0, 2 - y0, y1 = 0, 2 + x0, x1 = (0, 2) + y0, y1 = (0, 2) # Cut out and store im2 = im[y0:y1, x0:x1] @@ -352,7 +352,7 @@ def getSubRectangles(self, ims): # Done # print('%1.2f seconds to determine subrectangles of %i images' % # (time.time()-t0, len(ims2))) - return ims2, xy + return (ims2, xy) def convertImagesToPIL(self, images, dither, nq=0): """convertImagesToPIL(images, nq=0) @@ -377,7 +377,7 @@ def convertImagesToPIL(self, images, dither, nq=0): images2.append(im) # Convert to paletted PIL images - images, images2 = images2, [] + images, images2 = (images2, []) if nq >= 1: # NeuQuant algorithm for im in images: @@ -410,7 +410,7 @@ def writeGifToFile(self, fp, images, durations, loops, xys, disposes): """ # Obtain palette for all images and count each occurrence - palettes, occur = [], [] + palettes, occur = ([], []) for im in images: if not pillow: palette = getheader(im)[1] @@ -448,7 +448,7 @@ def writeGifToFile(self, fp, images, durations, loops, xys, disposes): # Write palette and image data # Gather info data = getdata(im) - imdes, data = data[0], data[1:] + imdes, data = (data[0], data[1:]) graphext = self.getGraphicsControlExt(durations[frames], disposes[frames]) # Make image descriptor suitable for using 256 local color palette lid = self.getImageDescriptor(im, xys[frames]) From 3dc4fc7c8735aeb840dedd1773bcfd923437a64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Fri, 3 Jan 2025 00:31:59 +0000 Subject: [PATCH 3/8] style: Add parenthesis for clarity --- python/grass/gunittest/case.py | 2 +- python/grass/jupyter/setup.py | 4 ++-- python/grass/temporal/spatial_topology_dataset_connector.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/grass/gunittest/case.py b/python/grass/gunittest/case.py index 791217d13c1..5fed86cdbed 100644 --- a/python/grass/gunittest/case.py +++ b/python/grass/gunittest/case.py @@ -1335,7 +1335,7 @@ def runModule(cls, module, expecting_stdout=False, **kwargs): module.name, module.get_python(), module.returncode, errors=errors ) # TODO: use this also in assert and apply when appropriate - if expecting_stdout and not module.outputs.stdout.strip(): + if expecting_stdout and (not module.outputs.stdout.strip()): if module.outputs.stderr: errors = " The errors are:\n" + module.outputs.stderr else: diff --git a/python/grass/jupyter/setup.py b/python/grass/jupyter/setup.py index 0ed64739039..0d7edec9767 100644 --- a/python/grass/jupyter/setup.py +++ b/python/grass/jupyter/setup.py @@ -87,8 +87,8 @@ def switch_mapset(self, path, location=None, mapset=None): gisenv = gs.gisenv() if ( not location - and not mapset - and len(Path(path).parts) == 1 + and (not mapset) + and (len(Path(path).parts) == 1) and mapset_exists( path=gisenv["GISDBASE"], location=gisenv["LOCATION_NAME"], mapset=path ) diff --git a/python/grass/temporal/spatial_topology_dataset_connector.py b/python/grass/temporal/spatial_topology_dataset_connector.py index 005ef2fcc45..7bd8d836f7b 100644 --- a/python/grass/temporal/spatial_topology_dataset_connector.py +++ b/python/grass/temporal/spatial_topology_dataset_connector.py @@ -296,7 +296,7 @@ def _generate_map_list_string(self, map_list, line_wrap: bool = True): count = 0 string = "" for map_ in map_list: - if line_wrap and count > 0 and count % 3 == 0: + if line_wrap and count > 0 and (count % 3 == 0): string += "\n | ............................ " count = 0 if count == 0: From 54e514275920688fb4bacaaff98ed98e917b6edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Fri, 3 Jan 2025 00:32:59 +0000 Subject: [PATCH 4/8] python: Rewrite negation --- python/grass/pygrass/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/grass/pygrass/utils.py b/python/grass/pygrass/utils.py index c9514c22c94..e66e421eeca 100644 --- a/python/grass/pygrass/utils.py +++ b/python/grass/pygrass/utils.py @@ -187,7 +187,7 @@ def is_clean_name(name) -> bool: False """ - return not libgis.G_legal_filename(name) < 0 + return libgis.G_legal_filename(name) >= 0 def coor2pixel(coord, region): From 246ef380a0e322fb7dc1d4344e97e65871f26d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Fri, 3 Jan 2025 00:33:39 +0000 Subject: [PATCH 5/8] style: Extract constant from loop --- python/grass/pygrass/modules/grid/grid.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/grass/pygrass/modules/grid/grid.py b/python/grass/pygrass/modules/grid/grid.py index cc3f406d72d..fd980766ba0 100644 --- a/python/grass/pygrass/modules/grid/grid.py +++ b/python/grass/pygrass/modules/grid/grid.py @@ -597,8 +597,9 @@ def get_works(self): if self.inlist: inms = {} cols = len(box_row) + + indx = row * cols + col for key in self.inlist: - indx = row * cols + col inms[key] = "%s@%s" % (self.inlist[key][indx], self.mset.name) # set the computational region, prepare the region parameters bbox = {k[0]: str(v) for k, v in box.items()[:-2]} From 7d3d20a541493e2912931c30b600c0f1d1db6989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Fri, 3 Jan 2025 00:34:16 +0000 Subject: [PATCH 6/8] style: Membership test using a set --- python/grass/gunittest/runner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/grass/gunittest/runner.py b/python/grass/gunittest/runner.py index 0bbd0f361b9..44daecc4e59 100644 --- a/python/grass/gunittest/runner.py +++ b/python/grass/gunittest/runner.py @@ -26,8 +26,8 @@ class _WritelnDecorator: def __init__(self, stream): self.stream = stream - def __getattr__(self, attr): - if attr in ("stream", "__getstate__"): + def __getattr__(self, attr: str): + if attr in {"stream", "__getstate__"}: raise AttributeError(attr) return getattr(self.stream, attr) From d94b5ab0c9fd127a80bd45d0deeafaf928b67bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Fri, 3 Jan 2025 00:35:40 +0000 Subject: [PATCH 7/8] style: Factor out commonly used strings into constants --- .../script/tests/grass_script_setup_test.py | 23 ++--- python/grass/temporal/mapcalc.py | 84 +++++-------------- 2 files changed, 34 insertions(+), 73 deletions(-) diff --git a/python/grass/script/tests/grass_script_setup_test.py b/python/grass/script/tests/grass_script_setup_test.py index 36dfbb77dbb..f2593d1e0ca 100644 --- a/python/grass/script/tests/grass_script_setup_test.py +++ b/python/grass/script/tests/grass_script_setup_test.py @@ -8,6 +8,9 @@ import grass.script as gs +RUNTIME_GISBASE_SHOULD_BE_PRESENT = "Runtime (GISBASE) should be present" +SESSION_FILE_NOT_DELETED = "Session file not deleted" + xfail_mp_spawn = pytest.mark.xfail( multiprocessing.get_start_method() == "spawn", reason="Multiprocessing using 'spawn' start method requires pickable functions", @@ -91,8 +94,8 @@ def test_init_finish_global_functions_capture_strerr0_partial(tmp_path): ) session_file, runtime_present = run_in_subprocess(init_finish) assert session_file, "Expected file name from the subprocess" - assert runtime_present, "Runtime (GISBASE) should be present" - assert not os.path.exists(session_file), "Session file not deleted" + assert runtime_present, RUNTIME_GISBASE_SHOULD_BE_PRESENT + assert not os.path.exists(session_file), SESSION_FILE_NOT_DELETED @xfail_mp_spawn @@ -113,8 +116,8 @@ def init_finish(queue): session_file, runtime_present = run_in_subprocess(init_finish) assert session_file, "Expected file name from the subprocess" - assert runtime_present, "Runtime (GISBASE) should be present" - assert not os.path.exists(session_file), "Session file not deleted" + assert runtime_present, RUNTIME_GISBASE_SHOULD_BE_PRESENT + assert not os.path.exists(session_file), SESSION_FILE_NOT_DELETED @xfail_mp_spawn @@ -139,8 +142,8 @@ def init_finish(queue): init_finish ) assert session_file, "Expected file name from the subprocess" - assert runtime_present, "Runtime (GISBASE) should be present" - assert not os.path.exists(session_file), "Session file not deleted" + assert runtime_present, RUNTIME_GISBASE_SHOULD_BE_PRESENT + assert not os.path.exists(session_file), SESSION_FILE_NOT_DELETED # This is testing the current implementation behavior, but it is not required # to be this way in terms of design. assert runtime_present_after, "Runtime should continue to be present" @@ -189,7 +192,7 @@ def init_finish(queue): ) = run_in_subprocess(init_finish) # Runtime - assert runtime_present_during, "Runtime (GISBASE) should be present" + assert runtime_present_during, RUNTIME_GISBASE_SHOULD_BE_PRESENT # This is testing the current implementation behavior, but it is not required # to be this way in terms of design. assert runtime_present_after, "Expected GISBASE to be present when finished" @@ -198,7 +201,7 @@ def init_finish(queue): assert session_file_present_during, "Expected session file to be present" assert session_file_variable_present_during, "Variable GISRC should be present" assert not session_file_variable_present_after, "Not expecting GISRC when finished" - assert not os.path.exists(session_file), "Session file not deleted" + assert not os.path.exists(session_file), SESSION_FILE_NOT_DELETED @xfail_mp_spawn @@ -220,8 +223,8 @@ def workload(queue): session_file, file_existed, runtime_present = run_in_subprocess(workload) assert session_file, "Expected file name from the subprocess" assert file_existed, "File should have been present" - assert runtime_present, "Runtime (GISBASE) should be present" - assert not os.path.exists(session_file), "Session file not deleted" + assert runtime_present, RUNTIME_GISBASE_SHOULD_BE_PRESENT + assert not os.path.exists(session_file), SESSION_FILE_NOT_DELETED assert not os.environ.get("GISRC") assert not os.environ.get("GISBASE") diff --git a/python/grass/temporal/mapcalc.py b/python/grass/temporal/mapcalc.py index b1dbb5ce2db..68b2918170c 100644 --- a/python/grass/temporal/mapcalc.py +++ b/python/grass/temporal/mapcalc.py @@ -25,6 +25,9 @@ from .datetime_math import time_delta_to_relative_time from .open_stds import check_new_stds, open_new_stds, open_old_stds +_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME = ( + "The temporal operators <%s> support only absolute time." +) ############################################################################ @@ -507,74 +510,47 @@ def _parse_start_operators(expr, is_time_absolute: bool, current): if expr.find("start_year()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") - % ("start_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("start_*")) expr = expr.replace("start_year()", str(start.year)) if expr.find("start_month()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") - % ("start_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("start_*")) expr = expr.replace("start_month()", str(start.month)) if expr.find("start_week()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") - % ("start_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("start_*")) expr = expr.replace("start_week()", str(start.isocalendar()[1])) if expr.find("start_day()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") - % ("start_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("start_*")) expr = expr.replace("start_day()", str(start.day)) if expr.find("start_hour()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") - % ("start_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("start_*")) expr = expr.replace("start_hour()", str(start.hour)) if expr.find("start_minute()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") - % ("start_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("start_*")) expr = expr.replace("start_minute()", str(start.minute)) if expr.find("start_second()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") - % ("start_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("start_*")) expr = expr.replace("start_second()", str(start.second)) if expr.find("start_dow()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") - % ("start_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("start_*")) expr = expr.replace("start_dow()", str(start.isoweekday())) if expr.find("start_doy()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") - % ("start_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("start_*")) year = datetime(start.year, 1, 1) delta = start - year @@ -609,9 +585,7 @@ def _parse_end_operators(expr, is_time_absolute: bool, current): if expr.find("end_year()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") % ("end_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("end_*")) if not end: expr = expr.replace("end_year()", "null()") else: @@ -619,9 +593,7 @@ def _parse_end_operators(expr, is_time_absolute: bool, current): if expr.find("end_month()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") % ("end_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("end_*")) if not end: expr = expr.replace("end_month()", "null()") else: @@ -629,9 +601,7 @@ def _parse_end_operators(expr, is_time_absolute: bool, current): if expr.find("end_week()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") % ("end_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("end_*")) if not end: expr = expr.replace("end_week()", "null()") else: @@ -639,9 +609,7 @@ def _parse_end_operators(expr, is_time_absolute: bool, current): if expr.find("end_day()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") % ("end_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("end_*")) if not end: expr = expr.replace("end_day()", "null()") else: @@ -649,9 +617,7 @@ def _parse_end_operators(expr, is_time_absolute: bool, current): if expr.find("end_hour()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") % ("end_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("end_*")) if not end: expr = expr.replace("end_hour()", "null()") else: @@ -659,9 +625,7 @@ def _parse_end_operators(expr, is_time_absolute: bool, current): if expr.find("end_minute()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") % ("end_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("end_*")) if not end: expr = expr.replace("end_minute()", "null()") else: @@ -669,9 +633,7 @@ def _parse_end_operators(expr, is_time_absolute: bool, current): if expr.find("end_second()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") % ("end_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("end_*")) if not end: expr = expr.replace("end_second()", "null()") else: @@ -679,9 +641,7 @@ def _parse_end_operators(expr, is_time_absolute: bool, current): if expr.find("end_dow()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") % ("end_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("end_*")) if not end: expr = expr.replace("end_dow()", "null()") else: @@ -689,9 +649,7 @@ def _parse_end_operators(expr, is_time_absolute: bool, current): if expr.find("end_doy()") >= 0: if not is_time_absolute: - msgr.fatal( - _("The temporal operators <%s> support only absolute time.") % ("end_*") - ) + msgr.fatal(_(_TEMPORAL_OPERATOR_SUPPORTS_ONLY_ABSOLUTE_TIME) % ("end_*")) if not end: expr = expr.replace("end_doy()", "null()") else: From bf53af9778d895602305acad03f1823fc03416d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Fri, 3 Jan 2025 02:10:34 +0000 Subject: [PATCH 8/8] checks: Remove fixed Ruff exclusions --- pyproject.toml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6acab49eca2..6a7033d9e69 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -131,7 +131,6 @@ ignore = [ "E501", # line-too-long "E721", # type-comparison "E722", # bare-except - "E731", # lambda-assignment "E741", # ambiguous-variable-name "F403", # undefined-local-with-import-star "F405", # undefined-local-with-import-star-usage @@ -149,7 +148,6 @@ ignore = [ "N803", # invalid-argument-name "N806", # non-lowercase-variable-in-function "N812", # lowercase-imported-as-non-lowercase - "N814", # camelcase-imported-as-constant "N815", # mixed-case-variable-in-class-scope "N816", # mixed-case-variable-in-global-scope "N818", # error-suffix-on-exception-name @@ -220,7 +218,6 @@ ignore = [ "S108", # hardcoded-temp-file "S110", # try-except-pass "S112", # try-except-continue - "S113", # request-without-timeout "S202", # tarfile-unsafe-members "S307", # suspicious-eval-usage "S310", # suspicious-url-open-usage @@ -240,12 +237,10 @@ ignore = [ "SIM102", # collapsible-if "SIM105", # suppressible-exception "SIM113", # enumerate-for-loop - "SIM116", # if-else-block-instead-of-dict-lookup "SIM118", # in-dict-keys "SIM223", # expr-and-false "SLF001", # private-member-access "TRY002", # raise-vanilla-class - "TRY003", # raise-vanilla-args "TRY004", # type-check-without-type-error "TRY201", # verbose-raise "TRY300", # try-consider-else @@ -262,10 +257,8 @@ ignore = [ # "A005", # builtin-module-shadowing # "PLW0108", # unnecessary-lambda # "SIM115", # open-file-with-context-handler -# Ignore `E402` (import violations) in all `__init__.py` files "**.py" = ["PYI066"] "*/testsuite/**.py" = ["PT009", "PT027"] -"__init__.py" = ["E402"] "display/d.mon/render_cmd.py" = ["SIM115"] "gui/**" = ["PLW0108"] # See https://github.com/OSGeo/grass/issues/4124 "gui/wxpython/animation/temporal_manager.py" = ["SIM115"] @@ -283,15 +276,15 @@ ignore = [ "gui/wxpython/icons/grass_icons.py" = ["PTH208"] "gui/wxpython/image2target/*.py" = ["SIM115"] "gui/wxpython/image2target/ii2t_manager.py" = ["PTH208"] -"gui/wxpython/iscatt/plots.py" = ["PLW0108"] "gui/wxpython/lmgr/workspace.py" = ["SIM115"] "gui/wxpython/location_wizard/wizard.py" = ["SIM115"] "gui/wxpython/mapdisp/main.py" = ["SIM115"] "gui/wxpython/modules/colorrules.py" = ["SIM115"] "gui/wxpython/modules/mcalc_builder.py" = ["SIM115"] -"gui/wxpython/photo2image/*.py" = ["SIM115"] -"gui/wxpython/psmap/*.py" = ["SIM115"] +"gui/wxpython/photo2image/ip2i_manager.py" = ["SIM115"] "gui/wxpython/psmap/dialogs.py" = ["PTH208"] +"gui/wxpython/psmap/frame.py" = ["SIM115"] +"gui/wxpython/psmap/instructions.py" = ["SIM115"] "gui/wxpython/psmap/utils.py" = ["PGH004"] "gui/wxpython/rdigit/controller.py" = ["SIM115"] "gui/wxpython/rlisetup/*.py" = ["SIM115"] @@ -300,7 +293,9 @@ ignore = [ "gui/wxpython/tools/update_menudata.py" = ["SIM115"] "gui/wxpython/tplot/frame.py" = ["FLY002"] "gui/wxpython/vdigit/mapwindow.py" = ["SIM115"] -"gui/wxpython/vnet/*.py" = ["SIM115"] +"gui/wxpython/vnet/vnet_core.py" = ["SIM115"] +"gui/wxpython/vnet/vnet_data.py" = ["SIM115"] +"gui/wxpython/vnet/widgets.py" = ["SIM115"] "gui/wxpython/web_services/dialogs.py" = ["SIM115"] "gui/wxpython/wxplot/profile.py" = ["A005", "SIM115"] "imagery/i.atcorr/create_iwave.py" = ["SIM115"] @@ -385,7 +380,6 @@ ignore = [ "temporal/t.register/testsuite/test_t_register_raster.py" = ["FLY002"] "temporal/t.register/testsuite/test_t_register_raster_file.py" = ["FLY002"] "temporal/t.remove/t.remove.py" = ["SIM115"] -"temporal/t.unregister/t.unregister.py" = ["SIM115"] "utils/**.py" = ["SIM115"] "utils/generate_release_notes.py" = ["PGH004"] "utils/thumbnails.py" = ["PTH208"]