Skip to content

Commit d96febf

Browse files
committed
remove validate-core-schema
1 parent e7c5dc7 commit d96febf

File tree

6 files changed

+4
-23
lines changed

6 files changed

+4
-23
lines changed

benches/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ use test::{black_box, Bencher};
88
use pyo3::prelude::*;
99
use pyo3::types::{PyDict, PyString};
1010

11-
use _pydantic_core::{validate_core_schema, SchemaValidator};
11+
use _pydantic_core::SchemaValidator;
1212

1313
fn build_schema_validator_with_globals(
1414
py: Python,
1515
code: &CStr,
1616
globals: Option<&Bound<'_, PyDict>>,
1717
) -> SchemaValidator {
1818
let mut schema = py.eval(code, globals, None).unwrap().extract().unwrap();
19-
schema = validate_core_schema(&schema, None).unwrap().extract().unwrap();
2019
SchemaValidator::py_new(py, &schema, None).unwrap()
2120
}
2221

python/pydantic_core/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from_json,
2626
to_json,
2727
to_jsonable_python,
28-
validate_core_schema,
2928
)
3029
from .core_schema import CoreConfig, CoreSchema, CoreSchemaType, ErrorType
3130

@@ -66,7 +65,6 @@
6665
'to_json',
6766
'from_json',
6867
'to_jsonable_python',
69-
'validate_core_schema',
7068
]
7169

7270

python/pydantic_core/_pydantic_core.pyi

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ __all__ = [
3434
'to_jsonable_python',
3535
'list_all_errors',
3636
'TzInfo',
37-
'validate_core_schema',
3837
]
3938
__version__: str
4039
build_profile: str
@@ -1003,11 +1002,3 @@ class TzInfo(datetime.tzinfo):
10031002

10041003
def __deepcopy__(self, _memo: dict[Any, Any]) -> TzInfo: ...
10051004

1006-
def validate_core_schema(schema: CoreSchema, *, strict: bool | None = None) -> CoreSchema:
1007-
"""Validate a core schema.
1008-
1009-
This currently uses lax mode for validation (i.e. will coerce strings to dates and such)
1010-
but may use strict mode in the future.
1011-
We may also remove this function altogether, do not rely on it being present if you are
1012-
using pydantic-core directly.
1013-
"""

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub use serializers::{
4040
to_json, to_jsonable_python, PydanticSerializationError, PydanticSerializationUnexpectedValue, SchemaSerializer,
4141
WarningsArg,
4242
};
43-
pub use validators::{validate_core_schema, PySome, SchemaValidator};
43+
pub use validators::{PySome, SchemaValidator};
4444

4545
use crate::input::Input;
4646

@@ -134,6 +134,5 @@ fn _pydantic_core(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
134134
m.add_function(wrap_pyfunction!(from_json, m)?)?;
135135
m.add_function(wrap_pyfunction!(to_jsonable_python, m)?)?;
136136
m.add_function(wrap_pyfunction!(list_all_errors, m)?)?;
137-
m.add_function(wrap_pyfunction!(validate_core_schema, m)?)?;
138137
Ok(())
139138
}

src/validators/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,6 @@ impl<'py> SelfValidator<'py> {
470470
}
471471
}
472472

473-
#[pyfunction(signature = (schema, *, strict = None))]
474-
pub fn validate_core_schema<'py>(schema: &Bound<'py, PyAny>, strict: Option<bool>) -> PyResult<Bound<'py, PyAny>> {
475-
let self_validator = SelfValidator::new(schema.py())?;
476-
self_validator.validate_schema(schema, strict)
477-
}
478-
479473
pub trait BuildValidator: Sized {
480474
const EXPECTED_TYPE: &'static str;
481475

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import pytest
1414
from typing_extensions import Literal
1515

16-
from pydantic_core import ArgsKwargs, SchemaValidator, ValidationError, validate_core_schema
16+
from pydantic_core import ArgsKwargs, SchemaValidator, ValidationError
1717
from pydantic_core.core_schema import CoreConfig
1818

1919
__all__ = 'Err', 'PyAndJson', 'plain_repr', 'infinite_generator'
@@ -53,7 +53,7 @@ class PyAndJsonValidator:
5353
def __init__(
5454
self, schema, config: CoreConfig | None = None, *, validator_type: Literal['json', 'python'] | None = None
5555
):
56-
self.validator = SchemaValidator(validate_core_schema(schema), config)
56+
self.validator = SchemaValidator(schema, config)
5757
self.validator_type = validator_type
5858

5959
def validate_python(self, py_input, strict: bool | None = None, context: Any = None):

0 commit comments

Comments
 (0)