Skip to content

Commit a5206e5

Browse files
Viicosdavidhewitt
andcommitted
Feedback
Co-authored-by: David Hewitt <[email protected]>
1 parent b9dbb34 commit a5206e5

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

python/pydantic_core/core_schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3372,7 +3372,7 @@ def arguments_parameter(
33723372
return _dict_not_none(name=name, schema=schema, mode=mode, alias=alias)
33733373

33743374

3375-
VarKwargsMode: TypeAlias = Literal['single', 'unpacked-typed-dict']
3375+
VarKwargsMode: TypeAlias = Literal['uniform', 'unpacked-typed-dict']
33763376

33773377

33783378
class ArgumentsSchema(TypedDict, total=False):
@@ -3419,7 +3419,7 @@ def arguments_schema(
34193419
arguments: The arguments to use for the arguments schema
34203420
populate_by_name: Whether to populate by name
34213421
var_args_schema: The variable args schema to use for the arguments schema
3422-
var_kwargs_mode: The validation mode to use for variadic keyword arguments. If `'single'`, every value of the
3422+
var_kwargs_mode: The validation mode to use for variadic keyword arguments. If `'uniform'`, every value of the
34233423
keyword arguments will be validated against the `var_kwargs_schema` schema. If `'unpacked-typed-dict'`,
34243424
the `schema` argument must be a [`typed_dict_schema`][pydantic_core.core_schema.typed_dict_schema]
34253425
var_kwargs_schema: The variable kwargs schema to use for the arguments schema

src/validators/arguments.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use super::{build_validator, BuildValidator, CombinedValidator, DefinitionsBuild
1919

2020
#[derive(Debug, PartialEq)]
2121
enum VarKwargsMode {
22-
Single,
22+
Uniform,
2323
UnpackedTypedDict,
2424
}
2525

@@ -28,10 +28,10 @@ impl FromStr for VarKwargsMode {
2828

2929
fn from_str(s: &str) -> Result<Self, Self::Err> {
3030
match s {
31-
"single" => Ok(Self::Single),
31+
"uniform" => Ok(Self::Uniform),
3232
"unpacked-typed-dict" => Ok(Self::UnpackedTypedDict),
3333
s => py_schema_err!(
34-
"Invalid var_kwargs mode: `{}`, expected `single` or `unpacked-typed-dict`",
34+
"Invalid var_kwargs mode: `{}`, expected `uniform` or `unpacked-typed-dict`",
3535
s
3636
),
3737
}
@@ -319,8 +319,8 @@ impl Validator for ArgumentsValidator {
319319
};
320320
if !used_kwargs.contains(either_str.as_cow()?.as_ref()) {
321321
match self.var_kwargs_mode {
322-
VarKwargsMode::Single => match self.var_kwargs_validator {
323-
Some(ref validator) => match validator.validate(py, value.borrow_input(), state) {
322+
VarKwargsMode::Uniform => match &self.var_kwargs_validator {
323+
Some(validator) => match validator.validate(py, value.borrow_input(), state) {
324324
Ok(value) => {
325325
output_kwargs
326326
.set_item(either_str.as_py_string(py, state.cache_str()), value)?;
@@ -362,9 +362,7 @@ impl Validator for ArgumentsValidator {
362362
output_kwargs.update(value.downcast_bound::<PyDict>(py).unwrap().as_mapping())?;
363363
}
364364
Err(ValError::LineErrors(line_errors)) => {
365-
for error in line_errors {
366-
errors.push(error);
367-
}
365+
errors.extend(line_errors);
368366
}
369367
Err(err) => return Err(err),
370368
}

tests/validators/test_arguments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ def test_build_missing_var_kwargs():
791791
],
792792
ids=repr,
793793
)
794-
def test_kwargs_single(py_and_json: PyAndJson, input_value, expected):
794+
def test_kwargs_uniform(py_and_json: PyAndJson, input_value, expected):
795795
v = py_and_json(
796796
{
797797
'type': 'arguments',

0 commit comments

Comments
 (0)