astral-sh/ruff · error · anyhow::Error

could not find any tasks matching the given criteria

Error message

could not find any tasks matching the given criteria

What it means

After the fixture name matches, `show-one` filters the fixture's parsed `<CURSOR>` tasks by the optional `--file-name` and `--index` criteria (`matches_task` requires equality on whichever filters are given); if no task survives, this guard fires. Values must correspond exactly to a Python file inside the fixture and a zero-based cursor index within that file.

Source

Thrown at crates/ty_completion_eval/src/main.rs:179

                tmp_eval_dir.path().display()
            )
        })?
        .to_path_buf();

    let sources = TaskSource::all(&truth)?;
    match args.command {
        Command::ShowOne(ref cmd) => {
            tmp_eval_dir.disable_cleanup(cmd.keep_tmp_dir);

            let Some(source) = sources
                .iter()
                .find(|source| cmd.matches_source_task(source))
            else {
                anyhow::bail!("could not find task named `{}`", cmd.task_name);
            };
            let tasks = source.to_tasks(&tmp_eval_path)?;
            let matching: Vec<&Task> = tasks.iter().filter(|task| cmd.matches_task(task)).collect();
            anyhow::ensure!(
                !matching.is_empty(),
                "could not find any tasks matching the given criteria",
            );
            anyhow::ensure!(
                matching.len() < 2,
                "found more than one task matching the given criteria",
            );
            let task = &matching[0];
            let completions = task.completions()?;

            let mut stdout = std::io::stdout().lock();
            for (i, c) in completions.iter().enumerate() {
                write!(stdout, "{}", c.name.as_str())?;
                if let Some(module_name) = c.module_name {
                    write!(stdout, " (module: {module_name})")?;
                }
                if task.cursor.answer.matches(c) {
                    write!(stdout, " (*, {}/{})", i + 1, completions.len())?;

View on GitHub (pinned to 672bb4edf0)

Solutions

  1. Check valid combinations in `crates/ty_completion_eval/completion-evaluation-tasks.csv` for the fixture you named
  2. Re-run with only `--file-name` to confirm the file exists in the fixture, then pick an index that is listed
  3. Count the `<CURSOR>` directives in the fixture file with `grep -c '<CURSOR' <file>` and use an index below that count

Example fix

# before (index 9 does not exist in the file)
cargo run -p ty_completion_eval -- show-one custom-types --file-name main.py --index 9
# after
cargo run -p ty_completion_eval -- show-one custom-types --file-name main.py --index 0
Defensive patterns

Strategy: validation

Validate before calling

grep "^$FIXTURE" crates/ty_completion_eval/completion-evaluation-tasks.csv | grep "$FILE_NAME" >/dev/null \
  || { echo "no task for fixture=$FIXTURE file=$FILE_NAME" >&2; exit 2; }
# also: INDEX must satisfy 0 <= INDEX < $(grep -c '<CURSOR' "truth/$FIXTURE/**/$FILE_NAME")

Prevention

When it happens

Trigger: A `--file-name` that is not among the fixture's files (wrong path or spelling), an `--index` at or beyond the number of `<CURSOR>` directives in that file, or filters written for a different fixture than the one named.

Common situations: Reading (fixture, file, index) triples from the completion-evaluation CSV and transcribing them incorrectly; assuming 1-based cursor indexes; referencing a file that only exists in another fixture.

Related errors


AI-assisted analysis of astral-sh/ruff@672bb4edf0 (2026-08-16). Data as JSON: /api/errors/f2dcd7a5a2d4119a. Report an issue: GitHub.