{"record":{"id":"691ff2351dfd5778","repo":"pydantic/monty","slug":"kwargs-not-supported-yet-cannot-be-combined-with-varkwargs","errorCode":null,"errorMessage":"`kwargs_not_supported_yet` cannot be combined with `varkwargs` — the flag rejects every kwarg up front, so there's nothing to collect","messagePattern":"`kwargs_not_supported_yet` cannot be combined with `varkwargs` — the flag rejects every kwarg up front, so there's nothing to collect","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/monty-macros/src/from_args.rs","lineNumber":267,"sourceCode":"                     signatures with a fixed maximum\");\n            }\n        }\n\n        if self.vectorcall && !(self.at_most_total && self.style == Style::Clinic) {\n            return err(\"`vectorcall` requires the default `clinic` style plus `at_most_total` \\\n                 — it models a `tp_vectorcall` fast path in front of a clinic parser\");\n        }\n\n        if self.kwarg_error_name.is_some() && !matches!(self.style, Style::Def | Style::Clinic | Style::Unpack) {\n            return err(\"`kwarg_error_name` is only meaningful with `style = def`, the default \\\n                 `clinic` style, or `style = unpack` (where it names the function in the \\\n                 `takes no keyword arguments` error) — the C families defer unknown-kwarg \\\n                 errors past binding\");\n        }\n\n        if self.kwargs_not_supported_yet {\n            if self.varkwargs_idx.is_some() {\n                return err(\"`kwargs_not_supported_yet` cannot be combined with `varkwargs` \\\n                     — the flag rejects every kwarg up front, so there's nothing to collect\");\n            }\n            if self.fields.iter().any(|f| matches!(f.kind, FieldKind::KwOnly)) {\n                return err(\"`kwargs_not_supported_yet` cannot be combined with `kw_only` fields \\\n                     — the flag rejects every kwarg up front, so kw_only slots are unreachable\");\n            }\n            if self.kwarg_error_name.is_some() {\n                return err(\"`kwargs_not_supported_yet` cannot be combined with `kwarg_error_name` \\\n                     — the override only applies to the unknown-kwarg dispatch path, which is skipped\");\n            }\n        }\n\n        // The runtime binder's fast path fills the first `n` positional slots\n        // and assumes that satisfies every required positional param — sound\n        // only if required positional fields precede defaulted ones (the same\n        // ordering Python enforces for `def` signatures).\n        let mut seen_positional_default = false;\n        for field in &self.fields {","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/pydantic/monty/blob/adc986b362e3961f407868cb118a99fe831b9e61/crates/monty-macros/src/from_args.rs#L249-L285","documentation":"A `#[derive(FromArgs)]` struct sets `kwargs_not_supported_yet` while also declaring a `varkwargs` (`**kwargs`) field. The flag makes the generated parser reject every keyword argument up front, so there would be no kwargs left to collect into the field — the two declarations contradict each other and are rejected at compile time.","triggerScenarios":"Compiling `#[derive(FromArgs)] #[from_args(kwargs_not_supported_yet)] struct Args { a: i64, #[from_args(varkwargs)] kw: Vec<(String, Value)> }`. Checked in `Signature::validate` (crates/monty-macros/src/from_args.rs:265-269).","commonSituations":"Adding `kwargs_not_supported_yet` as a temporary measure to a struct that already collects kwargs; merging two structs — one that rejects kwargs, one that collects them — without pruning attributes.","solutions":["Remove the `varkwargs` field if kwargs should be rejected.","Remove `kwargs_not_supported_yet` if the function genuinely accepts `**kwargs`; add kwarg support to the binder instead of using the escape-hatch flag."],"exampleFix":"// before\n#[derive(FromArgs)]\n#[from_args(kwargs_not_supported_yet)]\nstruct Args { a: Value, #[from_args(varkwargs)] kw: Vec<(String, Value)> }\n\n// after\n#[derive(FromArgs)]\n#[from_args(kwargs_not_supported_yet)]\nstruct Args { a: Value }","handlingStrategy":"validation","validationCode":"fn kwargs_flag_conflicts(kwargs_not_supported_yet: bool, has_varkwargs: bool) -> bool {\n    kwargs_not_supported_yet && has_varkwargs\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["kwargs_not_supported_yet is a rejection escape hatch — a struct using it must not collect kwargs.","Remove the flag as soon as kwarg support is added instead of accumulating contradictory attributes."],"tags":["rust","proc-macro","fromargs","compile-time"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"adc986b362e3961f407868cb118a99fe831b9e61","analyzedAt":"2026-09-13T19:19:18.698Z","contentChangedAt":"2026-09-13T19:19:18.698Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}