Skip to content

Commit db9509c

Browse files
committed
Remove core schema validation
The code used to generate the self schema is inspecting annotations in a way that isn't compatible with Python 3.14.
1 parent 22d34a7 commit db9509c

File tree

11 files changed

+4
-431
lines changed

11 files changed

+4
-431
lines changed

.github/actions/build-pgo-wheel/action.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ outputs:
1414
runs:
1515
using: "composite"
1616
steps:
17-
- name: prepare self schema
18-
shell: bash
19-
# generate up front so that we don't have to do this inside the docker container
20-
run: uv run python generate_self_schema.py
21-
2217
- name: prepare profiling directory
2318
shell: bash
2419
# making this ahead of the compile ensures that the local user can write to this

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,6 @@ jobs:
478478

479479
- run: pip install -U twine 'ruff==0.5.0' typing_extensions
480480

481-
# generate self-schema now, so we don't have to do so inside docker in maturin build
482-
- run: python generate_self_schema.py
483-
484481
- name: build wheels
485482
uses: PyO3/maturin-action@v1
486483
with:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ node_modules/
3434
/*.profraw
3535
/foobar.py
3636
/python/pydantic_core/*.so
37-
/src/self_schema.py
3837

3938
# samply
4039
/profile.json

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ include = [
1212
"/LICENSE",
1313
"/Makefile",
1414
"/build.rs",
15-
"/generate_self_schema.py",
1615
"/rust-toolchain",
1716
"/src",
18-
"!/src/self_schema.py",
1917
"/python/pydantic_core",
2018
"/tests",
2119
"/.cargo",

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.DEFAULT_GOAL := all
2-
sources = python/pydantic_core tests generate_self_schema.py wasm-preview/run_tests.py
2+
sources = python/pydantic_core tests wasm-preview/run_tests.py
33

44
mypy-stubtest = uv run python -m mypy.stubtest pydantic_core._pydantic_core --allowlist .mypy-stubtest-allowlist
55

@@ -124,7 +124,6 @@ clean:
124124
rm -f `find . -type f -name '*.py[co]' `
125125
rm -f `find . -type f -name '*~' `
126126
rm -f `find . -type f -name '.*~' `
127-
rm -rf src/self_schema.py
128127
rm -rf .cache
129128
rm -rf htmlcov
130129
rm -rf .pytest_cache

build.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,3 @@
1-
use std::env;
2-
use std::path::Path;
3-
use std::process::Command;
4-
use std::str::from_utf8;
5-
6-
fn generate_self_schema() {
7-
println!("cargo:rerun-if-changed=python/pydantic_core/core_schema.py");
8-
println!("cargo:rerun-if-changed=generate_self_schema.py");
9-
if Path::new("./src/self_schema.py").exists() && option_env!("CI") == Some("true") {
10-
// self_schema.py already exists and CI indicates we're running on a github actions build,
11-
// don't bother generating again
12-
return;
13-
}
14-
15-
let output = Command::new(
16-
env::var("PYTHON")
17-
.ok()
18-
.or_else(|| pyo3_build_config::get().executable.clone())
19-
.unwrap_or_else(|| "python3".to_owned()),
20-
)
21-
.arg("generate_self_schema.py")
22-
.output()
23-
.expect("failed to execute process");
24-
25-
if !output.status.success() {
26-
let stdout = from_utf8(&output.stdout).unwrap();
27-
let stderr = from_utf8(&output.stderr).unwrap();
28-
eprint!("{stdout}{stderr}");
29-
panic!("generate_self_schema.py failed with {}", output.status);
30-
}
31-
}
32-
331
fn main() {
342
pyo3_build_config::use_pyo3_cfgs();
353
if let Some(true) = version_check::supports_feature("coverage_attribute") {
@@ -44,7 +12,5 @@ fn main() {
4412
println!("cargo:rustc-cfg=specified_profile_use");
4513
}
4614
println!("cargo:rustc-check-cfg=cfg(specified_profile_use)");
47-
48-
generate_self_schema();
4915
println!("cargo:rustc-env=PROFILE={}", std::env::var("PROFILE").unwrap());
5016
}

generate_self_schema.py

Lines changed: 0 additions & 245 deletions
This file was deleted.

python/pydantic_core/_pydantic_core.pyi

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,12 +1010,3 @@ class TzInfo(datetime.tzinfo):
10101010
More info can be found at [`tzinfo.fromutc`][datetime.tzinfo.fromutc]."""
10111011

10121012
def __deepcopy__(self, _memo: dict[Any, Any]) -> TzInfo: ...
1013-
1014-
def validate_core_schema(schema: CoreSchema, *, strict: bool | None = None) -> CoreSchema:
1015-
"""Validate a core schema.
1016-
1017-
This currently uses lax mode for validation (i.e. will coerce strings to dates and such)
1018-
but may use strict mode in the future.
1019-
We may also remove this function altogether, do not rely on it being present if you are
1020-
using pydantic-core directly.
1021-
"""

python/pydantic_core/core_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ class DateSchema(TypedDict, total=False):
953953
gt: date
954954
now_op: Literal['past', 'future']
955955
# defaults to current local utc offset from `time.localtime().tm_gmtoff`
956-
# value is restricted to -86_400 < offset < 86_400 by bounds in generate_self_schema.py
956+
# value is restricted to -86_400 < offset < 86_400:
957957
now_utc_offset: int
958958
ref: str
959959
metadata: dict[str, Any]

0 commit comments

Comments
 (0)