METADATA 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. Metadata-Version: 2.4
  2. Name: pydantic_core
  3. Version: 2.41.5
  4. Classifier: Development Status :: 3 - Alpha
  5. Classifier: Programming Language :: Python
  6. Classifier: Programming Language :: Python :: 3
  7. Classifier: Programming Language :: Python :: 3 :: Only
  8. Classifier: Programming Language :: Python :: 3.9
  9. Classifier: Programming Language :: Python :: 3.10
  10. Classifier: Programming Language :: Python :: 3.11
  11. Classifier: Programming Language :: Python :: 3.12
  12. Classifier: Programming Language :: Python :: 3.13
  13. Classifier: Programming Language :: Python :: 3.14
  14. Classifier: Programming Language :: Python :: Implementation :: CPython
  15. Classifier: Programming Language :: Python :: Implementation :: PyPy
  16. Classifier: Programming Language :: Python :: Implementation :: GraalPy
  17. Classifier: Programming Language :: Rust
  18. Classifier: Framework :: Pydantic
  19. Classifier: Intended Audience :: Developers
  20. Classifier: Intended Audience :: Information Technology
  21. Classifier: Operating System :: POSIX :: Linux
  22. Classifier: Operating System :: Microsoft :: Windows
  23. Classifier: Operating System :: MacOS
  24. Classifier: Typing :: Typed
  25. Requires-Dist: typing-extensions>=4.14.1
  26. License-File: LICENSE
  27. Summary: Core functionality for Pydantic validation and serialization
  28. Home-Page: https://github.com/pydantic/pydantic-core
  29. Author-email: Samuel Colvin <s@muelcolvin.com>, Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>, David Montague <david@pydantic.dev>, David Hewitt <mail@davidhewitt.dev>, Sydney Runkle <sydneymarierunkle@gmail.com>, Victorien Plot <contact@vctrn.dev>
  30. License-Expression: MIT
  31. Requires-Python: >=3.9
  32. Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
  33. Project-URL: Homepage, https://github.com/pydantic/pydantic-core
  34. Project-URL: Funding, https://github.com/sponsors/samuelcolvin
  35. Project-URL: Source, https://github.com/pydantic/pydantic-core
  36. # pydantic-core
  37. [![CI](https://github.com/pydantic/pydantic-core/workflows/ci/badge.svg?event=push)](https://github.com/pydantic/pydantic-core/actions?query=event%3Apush+branch%3Amain+workflow%3Aci)
  38. [![Coverage](https://codecov.io/gh/pydantic/pydantic-core/branch/main/graph/badge.svg)](https://codecov.io/gh/pydantic/pydantic-core)
  39. [![pypi](https://img.shields.io/pypi/v/pydantic-core.svg)](https://pypi.python.org/pypi/pydantic-core)
  40. [![versions](https://img.shields.io/pypi/pyversions/pydantic-core.svg)](https://github.com/pydantic/pydantic-core)
  41. [![license](https://img.shields.io/github/license/pydantic/pydantic-core.svg)](https://github.com/pydantic/pydantic-core/blob/main/LICENSE)
  42. This package provides the core functionality for [pydantic](https://docs.pydantic.dev) validation and serialization.
  43. Pydantic-core is currently around 17x faster than pydantic V1.
  44. See [`tests/benchmarks/`](./tests/benchmarks/) for details.
  45. ## Example of direct usage
  46. _NOTE: You should not need to use pydantic-core directly; instead, use pydantic, which in turn uses pydantic-core._
  47. ```py
  48. from pydantic_core import SchemaValidator, ValidationError
  49. v = SchemaValidator(
  50. {
  51. 'type': 'typed-dict',
  52. 'fields': {
  53. 'name': {
  54. 'type': 'typed-dict-field',
  55. 'schema': {
  56. 'type': 'str',
  57. },
  58. },
  59. 'age': {
  60. 'type': 'typed-dict-field',
  61. 'schema': {
  62. 'type': 'int',
  63. 'ge': 18,
  64. },
  65. },
  66. 'is_developer': {
  67. 'type': 'typed-dict-field',
  68. 'schema': {
  69. 'type': 'default',
  70. 'schema': {'type': 'bool'},
  71. 'default': True,
  72. },
  73. },
  74. },
  75. }
  76. )
  77. r1 = v.validate_python({'name': 'Samuel', 'age': 35})
  78. assert r1 == {'name': 'Samuel', 'age': 35, 'is_developer': True}
  79. # pydantic-core can also validate JSON directly
  80. r2 = v.validate_json('{"name": "Samuel", "age": 35}')
  81. assert r1 == r2
  82. try:
  83. v.validate_python({'name': 'Samuel', 'age': 11})
  84. except ValidationError as e:
  85. print(e)
  86. """
  87. 1 validation error for model
  88. age
  89. Input should be greater than or equal to 18
  90. [type=greater_than_equal, context={ge: 18}, input_value=11, input_type=int]
  91. """
  92. ```
  93. ## Getting Started
  94. ### Prerequisites
  95. You'll need:
  96. 1. **[Rust](https://rustup.rs/)** - Rust stable (or nightly for coverage)
  97. 2. **[uv](https://docs.astral.sh/uv/getting-started/installation/)** - Fast Python package manager (will install Python 3.9+ automatically)
  98. 3. **[git](https://git-scm.com/)** - For version control
  99. 4. **[make](https://www.gnu.org/software/make/)** - For running development commands (or use `nmake` on Windows)
  100. ### Quick Start
  101. ```bash
  102. # Clone the repository (or from your fork)
  103. git clone git@github.com:pydantic/pydantic-core.git
  104. cd pydantic-core
  105. # Install all dependencies using uv, setup pre-commit hooks, and build the development version
  106. make install
  107. ```
  108. Verify your installation by running:
  109. ```bash
  110. make
  111. ```
  112. This runs a full development cycle: formatting, building, linting, and testing
  113. ### Development Commands
  114. Run `make help` to see all available commands, or use these common ones:
  115. ```bash
  116. make build-dev # to build the package during development
  117. make build-prod # to perform an optimised build for benchmarking
  118. make test # to run the tests
  119. make testcov # to run the tests and generate a coverage report
  120. make lint # to run the linter
  121. make format # to format python and rust code
  122. make all # to run to run build-dev + format + lint + test
  123. ```
  124. ### Useful Resources
  125. * [`python/pydantic_core/_pydantic_core.pyi`](./python/pydantic_core/_pydantic_core.pyi) - Python API types
  126. * [`python/pydantic_core/core_schema.py`](./python/pydantic_core/core_schema.py) - Core schema definitions
  127. * [`tests/`](./tests) - Comprehensive usage examples
  128. ## Profiling
  129. It's possible to profile the code using the [`flamegraph` utility from `flamegraph-rs`](https://github.com/flamegraph-rs/flamegraph). (Tested on Linux.) You can install this with `cargo install flamegraph`.
  130. Run `make build-profiling` to install a release build with debugging symbols included (needed for profiling).
  131. Once that is built, you can profile pytest benchmarks with (e.g.):
  132. ```bash
  133. flamegraph -- pytest tests/benchmarks/test_micro_benchmarks.py -k test_list_of_ints_core_py --benchmark-enable
  134. ```
  135. The `flamegraph` command will produce an interactive SVG at `flamegraph.svg`.
  136. ## Releasing
  137. 1. Bump package version locally. Do not just edit `Cargo.toml` on Github, you need both `Cargo.toml` and `Cargo.lock` to be updated.
  138. 2. Make a PR for the version bump and merge it.
  139. 3. Go to https://github.com/pydantic/pydantic-core/releases and click "Draft a new release"
  140. 4. In the "Choose a tag" dropdown enter the new tag `v<the.new.version>` and select "Create new tag on publish" when the option appears.
  141. 5. Enter the release title in the form "v<the.new.version> <YYYY-MM-DD>"
  142. 6. Click Generate release notes button
  143. 7. Click Publish release
  144. 8. Go to https://github.com/pydantic/pydantic-core/actions and ensure that all build for release are done successfully.
  145. 9. Go to https://pypi.org/project/pydantic-core/ and ensure that the latest release is published.
  146. 10. Done 🎉