Skip to content

grass.pygrass: Remove unreachable bare raise after fatal - #735

Open
echoix wants to merge 1 commit into
mainfrom
fix/lint-errors-batch
Open

echoix wants to merge 1 commit into
mainfrom
fix/lint-errors-batch

Conversation

@echoix

@echoix echoix commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Description

set_region_from_rast() and set_region() in pygrass/raster/abstract.py have a bare raise right after fatal(...). grass.script.fatal() always raises ScriptError or calls sys.exit(), so the bare raise never runs. Outside an except block it would also be a RuntimeError. This PR removes the two unreachable lines. Behavior is unchanged.

Motivation and context

Found by ruff's PLE0704 (bare raise outside exception handler) check.

How has this been tested?

Confirmed by reading grass.script.core.fatal, which always raises or exits. Ruff check and ruff format pass on the file. The module imports grass.lib, which needs a built GRASS, so I did not run the open-map code path.

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as before)

Checklist

  • PR title provides summary of the changes and starts with one of the pre-defined prefixes
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

Generated by Claude Code

In set_region_from_rast() and set_region(), the bare raise after
fatal() can never run: grass.script.fatal() either raises ScriptError
or calls sys.exit(), so it never returns. A bare raise outside an
except block would also be a RuntimeError, which is never reached.
Remove both lines.

The change was found and fixed with AI assistance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants