Skip to content

v0.11.0

Choose a tag to compare

@github-actions github-actions released this 09 Oct 04:52
· 77 commits to main since this release
e410d9f

Added

  • readme_task_args (IEFS007) checks the -T name=value arguments in the README's inspect eval and inspect eval-set commands, in fenced code blocks and inline code, with or without uv run and across line continuations. Each task the command names is resolved against the package's @task functions as <namespace>/<task>, a bare <task> or path/to/file.py@task, and every -T name must be a parameter of every resolved task. Inspect drops an argument the task does not take and only logs a warning, so the command runs with the default. Tasks that do not resolve to the package, such as placeholders and other packages' tasks, and tasks that take **kwargs are not checked. A README generator that rewrites a generated parameter list does not read the hand-written examples around it, which is how these drift. Findings are errors (#59).
  • readme_dependency_groups (IEFS008) checks the extras and dependency groups the README's commands install. In a uv command, --extra X must name an extra under [project.optional-dependencies] and --group X a group under [dependency-groups]. In a pip install (also pip3, python -m pip and uv pip) or uv add command, project[X] must name an extra when the project is the repository's own or .. Names are compared in normalised form. The governing pyproject.toml is the repository's, or the evaluation's own <isolated-packages-dir>/<name>/pyproject.toml when it has one, and the message names it. Other projects' extras, placeholders, uv commands with --project, --directory or --package, and commands after a cd in the same code block are not checked. A pyproject.toml that is not valid TOML skips the rule. A name that exists as the other kind gets a hint to switch flags. Findings are errors (#60).
  • metric_epoch_safety (IEBP014) checks custom metrics against the scores Inspect actually hands them. By default the epoch reducer runs before every metric, even at epochs=1: value can be an epoch mean such as 0.667, and answer, explanation and reason are None unless every epoch agrees. The rule reads each @metric function, including the function it returns and helpers nested in it, and each @score_reducer. It reports an error for .as_int(), .as_bool() or int(...) of anything computed from a score value in a metric, but not int(len(...)) or int() of a comparison. It warns on a single-type isinstance(v, int) or isinstance(v, float) applied directly to a score value; (int, float) and the isnan guard are not flagged. It reports an error for reading <x>.score.answer, .explanation or .reason in a metric, and for an attribute or subscript assignment into the scores a metric or reducer was handed. Names are followed in statement order, so rebinding one to a deep copy ends it, and a store into a field that a shallow model_copy() shares with the original is flagged. @metric(scores="unreduced") metrics see raw epoch scores, so only the last check applies to them. The hints recommend converting each value with the function value_to_float() returns, as accuracy() and mean() do, which holds under every reducer except collect. Score.as_float() raises on "C", and a type filter drops samples under mode or max. Nothing is followed into plain helper functions or other files (#58).
  • shared_code_extraction (IECQ006) warns where an evaluation extracts code from a completion with its own fence pattern instead of inspect_evals.utils.code.extract_code_block. It flags a string literal holding a triple-backtick fence, or a regex quantifier for three backticks, passed as the pattern to re.compile, search, findall, finditer, match, fullmatch or sub, or as a tag to extract_from_tags. As the separator to split, replace, find, partition or startswith it counts only with a language label, so a bare fence toggle while reading markdown does not warn. F-strings, + concatenations and names bound to a literal in the same function or at module level count, including a name inside a concatenation. There is one warning per function, and one for a file's module-level patterns. A pattern whose fences are all labelled json is left alone, and so is a bare closing fence beside one in the same function. A (?:json|python)? alternation still warns. Test files and the helper's own module are not read. The rule applies only where the helper is available: a helper package defines extract_code_block (inspect_evals itself), or the root pyproject.toml declares inspect-evals outside dev. Elsewhere it is skipped. The docs say a migration needs a task version bump, and that an evaluation whose upstream benchmark takes a different block should suppress with a reason (#62).
  • ruff_rules_enabled (IECQ007) warns when the ruff configuration governing a package does not enable a rule in a curated set of ruff rules that matter for evaluations. The set starts with PLW1514 (unspecified-encoding); each entry carries its justification on the rule page. The check asks ruff rather than parsing its configuration: it lints a snippet the rule reports as though it were a file in the package, so select prefixes, extend-select, ignore, extend, per-file-ignores, preview and explicit-preview-rules apply as ruff applies them. A preview rule selected by a prefix while preview is off counts as not enabled. A repository with no ruff configuration gets ruff's defaults, which enable none of the set. The message names the configuration file and how many violations ruff would report under the source root with the rule on. The rule uses the ruff package installed alongside the linter, else ruff on PATH, and skips when there is neither; ruff is not a runtime dependency. It also skips, with ruff's reason, when ruff cannot load the configuration, and a failing ruff is tried once per configuration in a run. A repository declines an entry with a reason under [tool.inspect-evals-lint.ruff_rules_enabled] declined, and the finding is then reported as suppressed (#64).
  • custom_metric_tests (IETS008) warns about each custom @metric that no test runs through the real epoch reducer. A test counts when it imports the epoch helper module, metric_epochs by default (tests/utils/metric_epochs.py in inspect_evals and the evaluation template), and names the metric as a whole word, or the name given in @metric(name=...). A hand-written test that runs eval() with epochs= is not counted. A unit test that hands a metric hand-built scores misses the reducer, which turns "C" into 1.0 even at epochs=1 and two passes in three epochs into 0.667. The helper module can be renamed with [tool.inspect-evals-lint.custom_metric_tests] helper-module, which takes a bare or dotted module name. It is a warning, and a presence check only.

Changed

  • A rule can mark a diagnostic as shared when it is about something several packages share, such as a repository-wide configuration file. A run lists an identical shared diagnostic once, under the first package that reports it, and each other package records a skip for the rule naming that package. The mechanism is opt-in: only ruff_rules_enabled uses it, and every other diagnostic stays with its package even when its text matches another package's, so no other results change.
  • The documentation pages that list every rule are built with the documentation site instead of committed: the rule index, the front page, llms.txt, llms-full.txt and rules.json. Every new rule changed them, so any two pull requests that added rules conflicted on them. mkdocs serve rebuilds them when a rule or the README changes. docs/rules/ and the README's configuration table are still generated and committed. docs/CHECKS.md stays as a pointer to the site's rule index, because releases up to 0.10.0 link to it.
  • The CLI's "More info about these checks" link goes to the site's rule index instead of docs/CHECKS.md on GitHub.