pydantic/monty · error · syn::Error

`vectorcall` requires the default `clinic` style plus `at_mo

Error message

`vectorcall` requires the default `clinic` style plus `at_most_total` — it models a `tp_vectorcall` fast path in front of a clinic parser

What it means

The `vectorcall` flag was used without the exact supporting configuration. `vectorcall` models a `tp_vectorcall` fast path in front of a clinic parser, which requires the default `clinic` style together with `at_most_total`; any other combination is rejected at compile time because the generated fast path would not line up with the parser.

Source

Thrown at crates/monty-macros/src/from_args.rs:254

            Style::Clinic | Style::C | Style::CNamed => {}
        }

        if self.at_most_total {
            if matches!(self.style, Style::Def | Style::Unpack) {
                return err(
                    "`at_most_total` cannot be combined with `style = def` or `style = unpack` \
                     — the total pre-count models `PyArg_ParseTupleAndKeywords`-family C parsers",
                );
            }
            if self.varargs_idx.is_some() || self.varkwargs_idx.is_some() {
                return err("`at_most_total` cannot be combined with `varargs` or `varkwargs` \
                     — the up-front total-count check is only meaningful for \
                     signatures with a fixed maximum");
            }
        }

        if self.vectorcall && !(self.at_most_total && self.style == Style::Clinic) {
            return err("`vectorcall` requires the default `clinic` style plus `at_most_total` \
                 — it models a `tp_vectorcall` fast path in front of a clinic parser");
        }

        if self.kwarg_error_name.is_some() && !matches!(self.style, Style::Def | Style::Clinic | Style::Unpack) {
            return err("`kwarg_error_name` is only meaningful with `style = def`, the default \
                 `clinic` style, or `style = unpack` (where it names the function in the \
                 `takes no keyword arguments` error) — the C families defer unknown-kwarg \
                 errors past binding");
        }

        if self.kwargs_not_supported_yet {
            if self.varkwargs_idx.is_some() {
                return err("`kwargs_not_supported_yet` cannot be combined with `varkwargs` \
                     — the flag rejects every kwarg up front, so there's nothing to collect");
            }
            if self.fields.iter().any(|f| matches!(f.kind, FieldKind::KwOnly)) {
                return err("`kwargs_not_supported_yet` cannot be combined with `kw_only` fields \
                     — the flag rejects every kwarg up front, so kw_only slots are unreachable");

View on GitHub (pinned to adc986b362)

Solutions

  1. Remove `vectorcall` unless the call is hot enough to need the fast path.
  2. If the fast path is needed, use the default `clinic` style and add `at_most_total` so the combination is `#[from_args(at_most_total, vectorcall)]`.
  3. Do not add `vectorcall` to structs with `style = "c"`, `"c_named"`, `"def"`, or `"unpack"`; only clinic-style parsers sit behind the vectorcall front.

Example fix

// before
#[derive(FromArgs)]
#[from_args(style = "c", vectorcall)]
struct Args { a: i64 }

// after
#[derive(FromArgs)]
#[from_args(at_most_total, vectorcall)]
struct Args { a: i64 }
Defensive patterns

Strategy: validation

Validate before calling

// vectorcall demands the exact pair clinic + at_most_total:
fn vectorcall_ok(style: &str, at_most_total: bool, vectorcall: bool) -> bool {
    !vectorcall || (at_most_total && style == "clinic")
}

Prevention

When it happens

Trigger: Compiling `#[derive(FromArgs)] #[from_args(vectorcall)]` with either `at_most_total` missing or the style set to something other than `clinic` (e.g. `style = "c"`). Checked in `Signature::validate` (crates/monty-macros/src/from_args.rs:253-256).

Common situations: Adding `vectorcall` for a hot-path optimization to an existing struct that uses a non-clinic style or lacks `at_most_total`; copying the flag from a struct that already had the full `clinic + at_most_total` setup.

Understand the failure class

Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.

Related errors


AI-assisted analysis of pydantic/monty@adc986b362 (2026-09-13). Data as JSON: /api/errors/606602d4a17d5ede. Report an issue: GitHub.