
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
This package provides the core functionality for pydantic validation and serialization.
Pydantic-core is currently around 17x faster than pydantic V1.
See tests/benchmarks/
for details.
NOTE: You should not need to use pydantic-core directly; instead, use pydantic, which in turn uses pydantic-core.
from pydantic_core import SchemaValidator, ValidationError
v = SchemaValidator(
{
'type': 'typed-dict',
'fields': {
'name': {
'type': 'typed-dict-field',
'schema': {
'type': 'str',
},
},
'age': {
'type': 'typed-dict-field',
'schema': {
'type': 'int',
'ge': 18,
},
},
'is_developer': {
'type': 'typed-dict-field',
'schema': {
'type': 'default',
'schema': {'type': 'bool'},
'default': True,
},
},
},
}
)
r1 = v.validate_python({'name': 'Samuel', 'age': 35})
assert r1 == {'name': 'Samuel', 'age': 35, 'is_developer': True}
# pydantic-core can also validate JSON directly
r2 = v.validate_json('{"name": "Samuel", "age": 35}')
assert r1 == r2
try:
v.validate_python({'name': 'Samuel', 'age': 11})
except ValidationError as e:
print(e)
"""
1 validation error for model
age
Input should be greater than or equal to 18
[type=greater_than_equal, context={ge: 18}, input_value=11, input_type=int]
"""
You'll need:
nmake
on Windows)# Clone the repository (or from your fork)
git clone git@github.com:pydantic/pydantic-core.git
cd pydantic-core
# Install all dependencies using uv, setup pre-commit hooks, and build the development version
make install
Verify your installation by running:
make
This runs a full development cycle: formatting, building, linting, and testing
Run make help
to see all available commands, or use these common ones:
make build-dev # to build the package during development
make build-prod # to perform an optimised build for benchmarking
make test # to run the tests
make testcov # to run the tests and generate a coverage report
make lint # to run the linter
make format # to format python and rust code
make all # to run to run build-dev + format + lint + test
python/pydantic_core/_pydantic_core.pyi
- Python API typespython/pydantic_core/core_schema.py
- Core schema definitionstests/
- Comprehensive usage examplesIt's possible to profile the code using the flamegraph
utility from flamegraph-rs
. (Tested on Linux.) You can install this with cargo install flamegraph
.
Run make build-profiling
to install a release build with debugging symbols included (needed for profiling).
Once that is built, you can profile pytest benchmarks with (e.g.):
flamegraph -- pytest tests/benchmarks/test_micro_benchmarks.py -k test_list_of_ints_core_py --benchmark-enable
The flamegraph
command will produce an interactive SVG at flamegraph.svg
.
Cargo.toml
on Github, you need both Cargo.toml
and Cargo.lock
to be updated.v<the.new.version>
and select "Create new tag on publish" when the option appears.FAQs
Core functionality for Pydantic validation and serialization
We found that pydantic_core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.