Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ use test::{black_box, Bencher};
use pyo3::prelude::*;
use pyo3::types::{PyDict, PyString};

use _pydantic_core::{validate_core_schema, SchemaValidator};
use _pydantic_core::SchemaValidator;

fn build_schema_validator_with_globals(
py: Python,
code: &CStr,
globals: Option<&Bound<'_, PyDict>>,
) -> SchemaValidator {
let mut schema = py.eval(code, globals, None).unwrap().extract().unwrap();
schema = validate_core_schema(&schema, None).unwrap().extract().unwrap();
SchemaValidator::py_new(py, &schema, None).unwrap()
}

Expand Down
2 changes: 0 additions & 2 deletions python/pydantic_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from_json,
to_json,
to_jsonable_python,
validate_core_schema,
)
from .core_schema import CoreConfig, CoreSchema, CoreSchemaType, ErrorType

Expand Down Expand Up @@ -66,7 +65,6 @@
'to_json',
'from_json',
'to_jsonable_python',
'validate_core_schema',
]


Expand Down
9 changes: 0 additions & 9 deletions python/pydantic_core/_pydantic_core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ __all__ = [
'to_jsonable_python',
'list_all_errors',
'TzInfo',
'validate_core_schema',
]
__version__: str
build_profile: str
Expand Down Expand Up @@ -1003,11 +1002,3 @@ class TzInfo(datetime.tzinfo):

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

def validate_core_schema(schema: CoreSchema, *, strict: bool | None = None) -> CoreSchema:
"""Validate a core schema.

This currently uses lax mode for validation (i.e. will coerce strings to dates and such)
but may use strict mode in the future.
We may also remove this function altogether, do not rely on it being present if you are
using pydantic-core directly.
"""
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub use serializers::{
to_json, to_jsonable_python, PydanticSerializationError, PydanticSerializationUnexpectedValue, SchemaSerializer,
WarningsArg,
};
pub use validators::{validate_core_schema, PySome, SchemaValidator};
pub use validators::{PySome, SchemaValidator};

use crate::input::Input;

Expand Down Expand Up @@ -134,6 +134,5 @@ fn _pydantic_core(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(from_json, m)?)?;
m.add_function(wrap_pyfunction!(to_jsonable_python, m)?)?;
m.add_function(wrap_pyfunction!(list_all_errors, m)?)?;
m.add_function(wrap_pyfunction!(validate_core_schema, m)?)?;
Ok(())
}
6 changes: 0 additions & 6 deletions src/validators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,6 @@ impl<'py> SelfValidator<'py> {
}
}

#[pyfunction(signature = (schema, *, strict = None))]
pub fn validate_core_schema<'py>(schema: &Bound<'py, PyAny>, strict: Option<bool>) -> PyResult<Bound<'py, PyAny>> {
let self_validator = SelfValidator::new(schema.py())?;
self_validator.validate_schema(schema, strict)
}

pub trait BuildValidator: Sized {
const EXPECTED_TYPE: &'static str;

Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import pytest
from typing_extensions import Literal

from pydantic_core import ArgsKwargs, SchemaValidator, ValidationError, validate_core_schema
from pydantic_core import ArgsKwargs, SchemaValidator, ValidationError
from pydantic_core.core_schema import CoreConfig

__all__ = 'Err', 'PyAndJson', 'plain_repr', 'infinite_generator'
Expand Down Expand Up @@ -53,7 +53,7 @@ class PyAndJsonValidator:
def __init__(
self, schema, config: CoreConfig | None = None, *, validator_type: Literal['json', 'python'] | None = None
):
self.validator = SchemaValidator(validate_core_schema(schema), config)
self.validator = SchemaValidator(schema, config)
self.validator_type = validator_type

def validate_python(self, py_input, strict: bool | None = None, context: Any = None):
Expand Down
Loading