{"record":{"id":"0f61ca2e2c4debad","repo":"pydantic/monty","slug":"kwargs-not-supported-yet-cannot-be-combined-with-kw-only","errorCode":null,"errorMessage":"`kwargs_not_supported_yet` cannot be combined with `kw_only` fields — the flag rejects every kwarg up front, so kw_only slots are unreachable","messagePattern":"`kwargs_not_supported_yet` cannot be combined with `kw_only` fields — the flag rejects every kwarg up front, so kw_only slots are unreachable","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/monty-macros/src/from_args.rs","lineNumber":271,"sourceCode":"        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 {\n            if !matches!(field.kind, FieldKind::PosOnly | FieldKind::PosOrKeyword) {\n                continue;\n            }\n            if field.default.is_some() {","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/pydantic/monty/blob/adc986b362e3961f407868cb118a99fe831b9e61/crates/monty-macros/src/from_args.rs#L253-L289","documentation":"A `#[derive(FromArgs)]` struct sets `kwargs_not_supported_yet` while declaring one or more `kw_only` fields. The flag rejects every keyword argument up front, making any keyword-only slot permanently unreachable — no caller could ever satisfy it. The macro rejects this dead-code configuration at compile time.","triggerScenarios":"Compiling `#[derive(FromArgs)] #[from_args(kwargs_not_supported_yet)] struct Args { #[from_args(kw_only)] key: Value }`. Checked in `Signature::validate` (crates/monty-macros/src/from_args.rs:270-273).","commonSituations":"Marking a struct's parameters `kw_only` to match a Python signature while the flag (added earlier as a TODO marker) is still present; forgetting to remove the flag once kwarg support lands.","solutions":["Remove `kwargs_not_supported_yet` — its purpose (a temporary stand-in until kwarg support exists) conflicts with having kw_only fields.","If kwargs must still be rejected, drop the `kw_only` field(s) and express the parameter as positional instead.","If a custom rejection message is wanted for other kwargs, `kwarg_error_name` may fit; note the separate error that it also cannot combine with this flag."],"exampleFix":"// before\n#[derive(FromArgs)]\n#[from_args(kwargs_not_supported_yet)]\nstruct Args { #[from_args(kw_only)] key: Value }\n\n// after\n#[derive(FromArgs)]\nstruct Args { #[from_args(kw_only)] key: Value }","handlingStrategy":"validation","validationCode":"fn kw_only_unreachable(kwargs_not_supported_yet: bool, has_kw_only: bool) -> bool {\n    kwargs_not_supported_yet && has_kw_only\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Any kw_only field implies kwargs are supported — the rejection flag must be gone by then.","Review #[from_args(...)] flags whenever adding a kw_only field to an existing struct."],"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-23T08:17:48.524Z"}