Skip to content

pre-commit: Use stable ruff rules instead of preview - #758

Open
echoix wants to merge 3 commits into
mainfrom
ruff-stable-rules
Open

echoix wants to merge 3 commits into
mainfrom
ruff-stable-rules

Conversation

@echoix

@echoix echoix commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Description

Stop using --preview for ruff check in pre-commit and in the Python code quality workflow. The preview-only pydoclint (DOC) selection and its ignores are removed from pyproject.toml, since they have no effect without preview and make ruff emit a warning.

Motivation and context

Preview mode brings less useful fixes; the stable rule set is preferred.

How has this been tested?

ruff check . passes with the stable settings and no warnings.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

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

Drop --preview from ruff in pre-commit and the Python code quality workflow, and remove the preview-only pydoclint (DOC) selection and ignores, which have no effect without preview.
wenzeslaus and others added 2 commits October 28, 2026 22:07
rand() drew from the generator shared by the whole program, which hands
out values to whichever thread asks first, so r.mapcalc evaluated
expressions with rand() on one thread only, whatever nprocs was.

Every rand() call draws one value per cell of a row, and every row
evaluates every call once, so a row draws columns times calls values.
r.mapcalc now builds an exact random number layout from the seed with a
row as its unit (in r3.mapcalc, the rows of all depths one after
another), and each row places a generator state of its own at its stream
before it is evaluated. The state is local to the evaluation of the row,
so the draws of different threads do not write to the same cache line.
The streams of an exact layout are the parts of the sequence which the
rows drew when they were evaluated one after another from the shared
generator, so the result for a seed stays the same as in earlier
versions and is the same for any nprocs, and rand() no longer turns off
parallel evaluation. A warning is given when the whole computation draws
more than 2^46 values, after which the values repeat plus a constant.

The seed is read with G_random_seed_from_option(), so a seed outside
-2147483648 to 4294967295 is now an error rather than being silently
reduced to its low 32 bits, and a seed with trailing characters is an
error rather than being cut off. The automatic seed comes from
G_random_generate_seed(), so it can be set with GRASS_RANDOM_SEED or
SOURCE_DATE_EPOCH, and is still written to the history.

rand() stays in the calc library. The library gains
calc_set_random_state(), through which a tool gives rand() a function
returning the calling thread's generator state, and r.mapcalc sets it to
the state it places for the row. When no function is set, rand() draws
from the generator shared by the whole program as before, so other users
of the library get the same values as before.
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.

3 participants