@@ -345,7 +345,7 @@ class StringSchema(TypedDict, total=False):
345
345
serialization : SerSchema
346
346
347
347
348
- def string_schema (
348
+ def str_schema (
349
349
* ,
350
350
pattern : str | None = None ,
351
351
max_length : int | None = None ,
@@ -363,7 +363,7 @@ def string_schema(
363
363
364
364
```py
365
365
from pydantic_core import SchemaValidator, core_schema
366
- schema = core_schema.string_schema (max_length=10, min_length=2)
366
+ schema = core_schema.str_schema (max_length=10, min_length=2)
367
367
v = SchemaValidator(schema)
368
368
assert v.validate_python('hello') == 'hello'
369
369
```
@@ -938,7 +938,7 @@ def tuple_positional_schema(
938
938
939
939
```py
940
940
from pydantic_core import SchemaValidator, core_schema
941
- schema = core_schema.tuple_positional_schema(core_schema.int_schema(), core_schema.string_schema ())
941
+ schema = core_schema.tuple_positional_schema(core_schema.int_schema(), core_schema.str_schema ())
942
942
v = SchemaValidator(schema)
943
943
assert v.validate_python((1, 'hello')) == (1, 'hello')
944
944
```
@@ -1223,7 +1223,7 @@ def dict_schema(
1223
1223
```py
1224
1224
from pydantic_core import SchemaValidator, core_schema
1225
1225
schema = core_schema.dict_schema(
1226
- keys_schema=core_schema.string_schema (), values_schema=core_schema.int_schema()
1226
+ keys_schema=core_schema.str_schema (), values_schema=core_schema.int_schema()
1227
1227
)
1228
1228
v = SchemaValidator(schema)
1229
1229
assert v.validate_python({'a': '1', 'b': 2}) == {'a': 1, 'b': 2}
@@ -1289,7 +1289,7 @@ def fn(v: Any, **kwargs) -> str:
1289
1289
assert 'hello' in v_str
1290
1290
return v_str + 'world'
1291
1291
1292
- schema = core_schema.function_before_schema(function=fn, schema=core_schema.string_schema ())
1292
+ schema = core_schema.function_before_schema(function=fn, schema=core_schema.str_schema ())
1293
1293
v = SchemaValidator(schema)
1294
1294
assert v.validate_python(b"hello ") == "b'hello 'world"
1295
1295
```
@@ -1330,7 +1330,7 @@ def fn(v: str, **kwargs) -> str:
1330
1330
assert 'hello' in v
1331
1331
return v + 'world'
1332
1332
1333
- schema = core_schema.function_after_schema(schema=core_schema.string_schema (), function=fn)
1333
+ schema = core_schema.function_after_schema(schema=core_schema.str_schema (), function=fn)
1334
1334
v = SchemaValidator(schema)
1335
1335
assert v.validate_python('hello ') == 'hello world'
1336
1336
```
@@ -1401,7 +1401,7 @@ def function_wrap_schema(
1401
1401
def fn(v: str, *, validator, **kwargs) -> str:
1402
1402
return validator(input_value=v) + 'world'
1403
1403
1404
- schema = core_schema.function_wrap_schema(function=fn, schema=core_schema.string_schema ())
1404
+ schema = core_schema.function_wrap_schema(function=fn, schema=core_schema.str_schema ())
1405
1405
v = SchemaValidator(schema)
1406
1406
assert v.validate_python('hello ') == 'hello world'
1407
1407
```
@@ -1493,7 +1493,7 @@ def with_default_schema(
1493
1493
1494
1494
```py
1495
1495
from pydantic_core import SchemaValidator, core_schema
1496
- schema = core_schema.with_default_schema(core_schema.string_schema (), default='hello')
1496
+ schema = core_schema.with_default_schema(core_schema.str_schema (), default='hello')
1497
1497
wrapper_schema = core_schema.typed_dict_schema(
1498
1498
{'a': core_schema.typed_dict_field(schema)}
1499
1499
)
@@ -1548,7 +1548,7 @@ def nullable_schema(
1548
1548
1549
1549
```py
1550
1550
from pydantic_core import SchemaValidator, core_schema
1551
- schema = core_schema.nullable_schema(core_schema.string_schema ())
1551
+ schema = core_schema.nullable_schema(core_schema.str_schema ())
1552
1552
v = SchemaValidator(schema)
1553
1553
assert v.validate_python(None) is None
1554
1554
```
@@ -1595,7 +1595,7 @@ def union_schema(
1595
1595
1596
1596
```py
1597
1597
from pydantic_core import SchemaValidator, core_schema
1598
- schema = core_schema.union_schema(core_schema.string_schema (), core_schema.int_schema())
1598
+ schema = core_schema.union_schema(core_schema.str_schema (), core_schema.int_schema())
1599
1599
v = SchemaValidator(schema)
1600
1600
assert v.validate_python('hello') == 'hello'
1601
1601
assert v.validate_python(1) == 1
@@ -1660,13 +1660,13 @@ def tagged_union_schema(
1660
1660
from pydantic_core import SchemaValidator, core_schema
1661
1661
apple_schema = core_schema.typed_dict_schema(
1662
1662
{
1663
- 'foo': core_schema.typed_dict_field(core_schema.string_schema ()),
1663
+ 'foo': core_schema.typed_dict_field(core_schema.str_schema ()),
1664
1664
'bar': core_schema.typed_dict_field(core_schema.int_schema()),
1665
1665
}
1666
1666
)
1667
1667
banana_schema = core_schema.typed_dict_schema(
1668
1668
{
1669
- 'foo': core_schema.typed_dict_field(core_schema.string_schema ()),
1669
+ 'foo': core_schema.typed_dict_field(core_schema.str_schema ()),
1670
1670
'spam': core_schema.typed_dict_field(core_schema.list_schema(items_schema=core_schema.int_schema())),
1671
1671
}
1672
1672
)
@@ -1729,7 +1729,7 @@ def fn(v: str, **kwargs) -> str:
1729
1729
return v + ' world'
1730
1730
1731
1731
fn_schema = core_schema.function_plain_schema(function=fn)
1732
- schema = core_schema.chain_schema(fn_schema, fn_schema, fn_schema, core_schema.string_schema ())
1732
+ schema = core_schema.chain_schema(fn_schema, fn_schema, fn_schema, core_schema.str_schema ())
1733
1733
v = SchemaValidator(schema)
1734
1734
assert v.validate_python("hello") == 'hello world world world'
1735
1735
```
@@ -1873,7 +1873,7 @@ def typed_dict_schema(
1873
1873
```py
1874
1874
from pydantic_core import SchemaValidator, core_schema
1875
1875
wrapper_schema = core_schema.typed_dict_schema(
1876
- {'a': core_schema.typed_dict_field(core_schema.string_schema ())}
1876
+ {'a': core_schema.typed_dict_field(core_schema.str_schema ())}
1877
1877
)
1878
1878
v = SchemaValidator(wrapper_schema)
1879
1879
assert v.validate_python({'a': 'hello'}) == {'a': 'hello'}
@@ -1948,7 +1948,7 @@ class MyModel:
1948
1948
cls=MyModel,
1949
1949
config=CoreConfig(str_max_length=5),
1950
1950
schema=core_schema.typed_dict_schema(
1951
- fields={'a': core_schema.typed_dict_field(core_schema.string_schema ())},
1951
+ fields={'a': core_schema.typed_dict_field(core_schema.str_schema ())},
1952
1952
),
1953
1953
)
1954
1954
v = SchemaValidator(schema)
@@ -1998,7 +1998,7 @@ def arguments_parameter(
1998
1998
1999
1999
```py
2000
2000
from pydantic_core import SchemaValidator, core_schema
2001
- param = core_schema.arguments_parameter(name='a', schema=core_schema.string_schema (), mode='positional_only')
2001
+ param = core_schema.arguments_parameter(name='a', schema=core_schema.str_schema (), mode='positional_only')
2002
2002
```
2003
2003
2004
2004
Args:
@@ -2035,7 +2035,7 @@ def arguments_schema(
2035
2035
2036
2036
```py
2037
2037
from pydantic_core import SchemaValidator, core_schema
2038
- param_a = core_schema.arguments_parameter(name='a', schema=core_schema.string_schema (), mode='positional_only')
2038
+ param_a = core_schema.arguments_parameter(name='a', schema=core_schema.str_schema (), mode='positional_only')
2039
2039
param_b = core_schema.arguments_parameter(name='b', schema=core_schema.bool_schema(), mode='positional_only')
2040
2040
schema = core_schema.arguments_schema(param_a, param_b)
2041
2041
v = SchemaValidator(schema)
@@ -2087,14 +2087,14 @@ def call_schema(
2087
2087
2088
2088
```py
2089
2089
from pydantic_core import SchemaValidator, core_schema
2090
- param_a = core_schema.arguments_parameter(name='a', schema=core_schema.string_schema (), mode='positional_only')
2090
+ param_a = core_schema.arguments_parameter(name='a', schema=core_schema.str_schema (), mode='positional_only')
2091
2091
param_b = core_schema.arguments_parameter(name='b', schema=core_schema.bool_schema(), mode='positional_only')
2092
2092
args_schema = core_schema.arguments_schema(param_a, param_b)
2093
2093
2094
2094
schema = core_schema.call_schema(
2095
2095
arguments=args_schema,
2096
2096
function=lambda a, b: a + str(not b),
2097
- return_schema=core_schema.string_schema (),
2097
+ return_schema=core_schema.str_schema (),
2098
2098
)
2099
2099
v = SchemaValidator(schema)
2100
2100
assert v.validate_python((('hello', True))) == 'helloFalse'
@@ -2218,7 +2218,7 @@ def json_schema(
2218
2218
from pydantic_core import SchemaValidator, core_schema
2219
2219
dict_schema = core_schema.typed_dict_schema(
2220
2220
{
2221
- 'field_a': core_schema.typed_dict_field(core_schema.string_schema ()),
2221
+ 'field_a': core_schema.typed_dict_field(core_schema.str_schema ()),
2222
2222
'field_b': core_schema.typed_dict_field(core_schema.bool_schema()),
2223
2223
}
2224
2224
)
0 commit comments