[GRASS-git] [OSGeo/grass] bcca89: style: Fix raise-without-from-inside-except (B904)...

Edouard Choinière noreply at github.com
Fri Jul 17 09:05:29 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: bcca890878070c434e8cb93433d0c597bbf7e9e9
      https://github.com/OSGeo/grass/commit/bcca890878070c434e8cb93433d0c597bbf7e9e9
  Author: Edouard Choinière <27212526+echoix at users.noreply.github.com>
  Date:   2026-07-17 (Fri, 17 Jul 2026)

  Changed paths:
    M gui/wxpython/animation/data.py
    M gui/wxpython/animation/nviztask.py
    M gui/wxpython/core/settings.py
    M gui/wxpython/core/utils.py
    M gui/wxpython/dbmgr/base.py
    M gui/wxpython/gmodeler/model.py
    M gui/wxpython/gui_core/forms.py
    M gui/wxpython/gui_core/toolbars.py
    M gui/wxpython/mapdisp/main.py
    M gui/wxpython/rdigit/controller.py
    M gui/wxpython/wxgui.py
    M pyproject.toml
    M python/grass/gunittest/case.py
    M python/grass/imaging/images2avi.py
    M python/grass/pydispatch/dispatcher.py
    M python/grass/pygrass/raster/category.py
    M python/grass/pygrass/rpc/base.py
    M python/grass/pygrass/vector/table.py
    M python/grass/script/core.py
    M python/grass/script/task.py
    M python/grass/script/utils.py
    M python/grass/script/vector.py
    M python/grass/semantic_label/reader.py
    M python/grass/utils/download.py
    M scripts/r.in.wms/wms_cap_parsers.py

  Log Message:
  -----------
  style: Fix raise-without-from-inside-except (B904) (#4032)

Enable the ruff B904 rule and add explicit exception chaining to raise
statements inside except clauses.

Most exceptions are chained with "from error" to preserve the original,
including where the original is also passed into the message of the new
exception, so the detail is both in the message and in the chained traceback;
reducing that duplication is left for later. "from None" is used where the
original would be noise: where it is an implementation detail of the raising
code (for example, IndexError becoming StopIteration) or where the new
exception gives a clearer replacement message (for example, an invalid value
for a database column). In wxGUI, the original error is passed into the new
exception and "from None" is used; that exception is caught immediately and
only its message is shown, so no traceback is produced.

The change covers wxGUI, grass.script, grass.pygrass, grass.gunittest,
grass.imaging, grass.pydispatch, grass.semantic_label, grass.utils, and
r.in.wms.

Related bug fixes included:

* rdigit: "raise ScriptError" raised the class, not an instance. ScriptError
  requires a message argument, so this raised TypeError instead, which the
  callers' "except ScriptError" handlers did not catch. A failing r.mapcalc
  or g.copy resulted in a traceback instead of showing an error message. The
  message of the module error is now passed to ScriptError.
* wxGUI toolbars: Remove an unreachable return statement after a raise.
* wxGUI utils: Remove a dead try-except in __ll_parts which could not be
  reached and only re-raised an empty ValueError.



To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications


More information about the grass-commit mailing list