pydantic 2.2.0__tar.gz → 2.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. {pydantic-2.2.0 → pydantic-2.3.0}/HISTORY.md +30 -0
  2. {pydantic-2.2.0 → pydantic-2.3.0}/Makefile +1 -0
  3. {pydantic-2.2.0 → pydantic-2.3.0}/PKG-INFO +33 -3
  4. {pydantic-2.2.0 → pydantic-2.3.0}/README.md +1 -1
  5. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_core_utils.py +6 -2
  6. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_dataclasses.py +1 -1
  7. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_fields.py +3 -3
  8. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_generate_schema.py +17 -8
  9. pydantic-2.3.0/pydantic/_internal/_mock_val_ser.py +118 -0
  10. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_model_construction.py +5 -5
  11. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/errors.py +1 -0
  12. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/functional_validators.py +3 -3
  13. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/json_schema.py +2 -2
  14. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/main.py +11 -3
  15. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/root_model.py +9 -0
  16. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/types.py +2 -0
  17. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/version.py +1 -1
  18. {pydantic-2.2.0 → pydantic-2.3.0}/pyproject.toml +1 -1
  19. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_config.py +58 -6
  20. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_dataclasses.py +4 -4
  21. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_datetime.py +14 -0
  22. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_deprecated.py +57 -1
  23. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_edge_cases.py +0 -7
  24. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_json_schema.py +19 -0
  25. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_main.py +35 -0
  26. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_root_model.py +0 -1
  27. pydantic-2.2.0/pydantic/_internal/_mock_validator.py +0 -86
  28. {pydantic-2.2.0 → pydantic-2.3.0}/.gitignore +0 -0
  29. {pydantic-2.2.0 → pydantic-2.3.0}/LICENSE +0 -0
  30. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/__init__.py +0 -0
  31. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/__init__.py +0 -0
  32. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_annotated_handlers.py +0 -0
  33. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_config.py +0 -0
  34. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_core_metadata.py +0 -0
  35. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_decorators.py +0 -0
  36. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_decorators_v1.py +0 -0
  37. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_discriminated_union.py +0 -0
  38. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_forward_ref.py +0 -0
  39. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_generics.py +0 -0
  40. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_internal_dataclass.py +0 -0
  41. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_known_annotated_metadata.py +0 -0
  42. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_repr.py +0 -0
  43. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_schema_generation_shared.py +0 -0
  44. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_std_types_schema.py +0 -0
  45. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_typing_extra.py +0 -0
  46. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_utils.py +0 -0
  47. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_validate_call.py +0 -0
  48. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_internal/_validators.py +0 -0
  49. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/_migration.py +0 -0
  50. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/alias_generators.py +0 -0
  51. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/class_validators.py +0 -0
  52. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/color.py +0 -0
  53. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/config.py +0 -0
  54. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/dataclasses.py +0 -0
  55. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/datetime_parse.py +0 -0
  56. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/decorator.py +0 -0
  57. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/deprecated/__init__.py +0 -0
  58. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/deprecated/class_validators.py +0 -0
  59. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/deprecated/config.py +0 -0
  60. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/deprecated/copy_internals.py +0 -0
  61. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/deprecated/decorator.py +0 -0
  62. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/deprecated/json.py +0 -0
  63. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/deprecated/parse.py +0 -0
  64. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/deprecated/tools.py +0 -0
  65. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/env_settings.py +0 -0
  66. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/error_wrappers.py +0 -0
  67. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/fields.py +0 -0
  68. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/functional_serializers.py +0 -0
  69. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/generics.py +0 -0
  70. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/json.py +0 -0
  71. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/mypy.py +0 -0
  72. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/networks.py +0 -0
  73. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/parse.py +0 -0
  74. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/py.typed +0 -0
  75. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/schema.py +0 -0
  76. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/tools.py +0 -0
  77. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/type_adapter.py +0 -0
  78. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/typing.py +0 -0
  79. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/utils.py +0 -0
  80. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/__init__.py +0 -0
  81. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/_hypothesis_plugin.py +0 -0
  82. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/annotated_types.py +0 -0
  83. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/class_validators.py +0 -0
  84. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/color.py +0 -0
  85. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/config.py +0 -0
  86. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/dataclasses.py +0 -0
  87. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/datetime_parse.py +0 -0
  88. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/decorator.py +0 -0
  89. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/env_settings.py +0 -0
  90. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/error_wrappers.py +0 -0
  91. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/errors.py +0 -0
  92. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/fields.py +0 -0
  93. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/generics.py +0 -0
  94. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/json.py +0 -0
  95. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/main.py +0 -0
  96. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/mypy.py +0 -0
  97. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/networks.py +0 -0
  98. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/parse.py +0 -0
  99. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/py.typed +0 -0
  100. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/schema.py +0 -0
  101. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/tools.py +0 -0
  102. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/types.py +0 -0
  103. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/typing.py +0 -0
  104. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/utils.py +0 -0
  105. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/validators.py +0 -0
  106. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/v1/version.py +0 -0
  107. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/validate_call.py +0 -0
  108. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/validators.py +0 -0
  109. {pydantic-2.2.0 → pydantic-2.3.0}/pydantic/warnings.py +0 -0
  110. {pydantic-2.2.0 → pydantic-2.3.0}/tests/__init__.py +0 -0
  111. {pydantic-2.2.0 → pydantic-2.3.0}/tests/benchmarks/__init__.py +0 -0
  112. {pydantic-2.2.0 → pydantic-2.3.0}/tests/benchmarks/generate_north_star_data.py +0 -0
  113. {pydantic-2.2.0 → pydantic-2.3.0}/tests/benchmarks/test_fastapi_startup.py +0 -0
  114. {pydantic-2.2.0 → pydantic-2.3.0}/tests/benchmarks/test_north_star.py +0 -0
  115. {pydantic-2.2.0 → pydantic-2.3.0}/tests/conftest.py +0 -0
  116. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/__init__.py +0 -0
  117. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/configs/mypy-default.ini +0 -0
  118. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/configs/mypy-plugin-strict-no-any.ini +0 -0
  119. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/configs/mypy-plugin-strict.ini +0 -0
  120. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/configs/mypy-plugin-very-strict.ini +0 -0
  121. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/configs/mypy-plugin.ini +0 -0
  122. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/configs/pyproject-default.toml +0 -0
  123. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/configs/pyproject-plugin-bad-param.toml +0 -0
  124. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/configs/pyproject-plugin-strict.toml +0 -0
  125. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/configs/pyproject-plugin.toml +0 -0
  126. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/computed_fields.py +0 -0
  127. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/custom_constructor.py +0 -0
  128. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/dataclass_no_any.py +0 -0
  129. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/fail1.py +0 -0
  130. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/fail2.py +0 -0
  131. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/fail3.py +0 -0
  132. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/fail4.py +0 -0
  133. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/fail_defaults.py +0 -0
  134. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/generics.py +0 -0
  135. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/metaclass_args.py +0 -0
  136. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/plugin_default_factory.py +0 -0
  137. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/plugin_fail.py +0 -0
  138. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/plugin_fail_baseConfig.py +0 -0
  139. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/plugin_success.py +0 -0
  140. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/plugin_success_baseConfig.py +0 -0
  141. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/pydantic_settings.py +0 -0
  142. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/modules/success.py +0 -0
  143. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-default_ini/fail1.py +0 -0
  144. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-default_ini/fail2.py +0 -0
  145. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-default_ini/fail3.py +0 -0
  146. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-default_ini/fail4.py +0 -0
  147. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-default_ini/metaclass_args.py +0 -0
  148. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-default_ini/plugin_success.py +0 -0
  149. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-default_ini/plugin_success_baseConfig.py +0 -0
  150. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-default_ini/pydantic_settings.py +0 -0
  151. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-default_ini/success.py +0 -0
  152. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin-strict-no-any_ini/dataclass_no_any.py +0 -0
  153. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin-strict_ini/fail_defaults.py +0 -0
  154. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin-strict_ini/plugin_default_factory.py +0 -0
  155. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin-strict_ini/plugin_fail.py +0 -0
  156. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin-strict_ini/plugin_fail_baseConfig.py +0 -0
  157. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin-strict_ini/plugin_success.py +0 -0
  158. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin-strict_ini/plugin_success_baseConfig.py +0 -0
  159. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin-very-strict_ini/metaclass_args.py +0 -0
  160. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/custom_constructor.py +0 -0
  161. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/generics.py +0 -0
  162. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/plugin_fail.py +0 -0
  163. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/plugin_fail_baseConfig.py +0 -0
  164. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/plugin_success.py +0 -0
  165. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/plugin_success_baseConfig.py +0 -0
  166. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/pydantic_settings.py +0 -0
  167. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-default_toml/computed_fields.py +0 -0
  168. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-default_toml/fail1.py +0 -0
  169. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-default_toml/fail2.py +0 -0
  170. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-default_toml/fail3.py +0 -0
  171. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-default_toml/fail4.py +0 -0
  172. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-default_toml/pydantic_settings.py +0 -0
  173. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-default_toml/success.py +0 -0
  174. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-plugin-strict_toml/fail_defaults.py +0 -0
  175. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-plugin-strict_toml/plugin_fail.py +0 -0
  176. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-plugin-strict_toml/plugin_fail_baseConfig.py +0 -0
  177. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-plugin-strict_toml/plugin_success.py +0 -0
  178. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-plugin-strict_toml/plugin_success_baseConfig.py +0 -0
  179. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-plugin_toml/plugin_fail.py +0 -0
  180. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-plugin_toml/plugin_fail_baseConfig.py +0 -0
  181. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-plugin_toml/plugin_success.py +0 -0
  182. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-plugin_toml/plugin_success_baseConfig.py +0 -0
  183. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.0.1/pyproject-plugin_toml/pydantic_settings.py +0 -0
  184. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.1.1/mypy-default_ini/fail1.py +0 -0
  185. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.1.1/mypy-default_ini/fail2.py +0 -0
  186. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.1.1/mypy-default_ini/metaclass_args.py +0 -0
  187. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.1.1/mypy-default_ini/plugin_success.py +0 -0
  188. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.1.1/mypy-default_ini/plugin_success_baseConfig.py +0 -0
  189. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.1.1/mypy-default_ini/pydantic_settings.py +0 -0
  190. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.1.1/pyproject-default_toml/fail1.py +0 -0
  191. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.1.1/pyproject-default_toml/fail2.py +0 -0
  192. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.1.1/pyproject-default_toml/pydantic_settings.py +0 -0
  193. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.2.0/mypy-default_ini/plugin_success.py +0 -0
  194. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.2.0/mypy-default_ini/plugin_success_baseConfig.py +0 -0
  195. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.2.0/mypy-plugin-strict_ini/plugin_fail.py +0 -0
  196. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.2.0/mypy-plugin-strict_ini/plugin_fail_baseConfig.py +0 -0
  197. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.2.0/mypy-plugin_ini/plugin_fail.py +0 -0
  198. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.2.0/mypy-plugin_ini/plugin_fail_baseConfig.py +0 -0
  199. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.2.0/pyproject-plugin-strict_toml/plugin_fail.py +0 -0
  200. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.2.0/pyproject-plugin-strict_toml/plugin_fail_baseConfig.py +0 -0
  201. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.2.0/pyproject-plugin_toml/plugin_fail.py +0 -0
  202. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.2.0/pyproject-plugin_toml/plugin_fail_baseConfig.py +0 -0
  203. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/mypy-default_ini/fail4.py +0 -0
  204. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/mypy-default_ini/plugin_success.py +0 -0
  205. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/mypy-plugin-strict_ini/plugin_default_factory.py +0 -0
  206. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/mypy-plugin-strict_ini/plugin_fail.py +0 -0
  207. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/mypy-plugin-strict_ini/plugin_fail_baseConfig.py +0 -0
  208. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/mypy-plugin_ini/plugin_fail.py +0 -0
  209. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/mypy-plugin_ini/plugin_fail_baseConfig.py +0 -0
  210. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/mypy-plugin_ini/pydantic_settings.py +0 -0
  211. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/pyproject-default_toml/fail4.py +0 -0
  212. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/pyproject-plugin-strict_toml/plugin_fail.py +0 -0
  213. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/pyproject-plugin-strict_toml/plugin_fail_baseConfig.py +0 -0
  214. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/pyproject-plugin_toml/plugin_fail.py +0 -0
  215. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/pyproject-plugin_toml/plugin_fail_baseConfig.py +0 -0
  216. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/outputs/1.4.1/pyproject-plugin_toml/pydantic_settings.py +0 -0
  217. {pydantic-2.2.0 → pydantic-2.3.0}/tests/mypy/test_mypy.py +0 -0
  218. {pydantic-2.2.0 → pydantic-2.3.0}/tests/pyright/pyproject.toml +0 -0
  219. {pydantic-2.2.0 → pydantic-2.3.0}/tests/pyright/pyright_example.py +0 -0
  220. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_abc.py +0 -0
  221. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_aliases.py +0 -0
  222. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_annotated.py +0 -0
  223. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_assert_in_validators.py +0 -0
  224. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_callable.py +0 -0
  225. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_color.py +0 -0
  226. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_computed_fields.py +0 -0
  227. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_construction.py +0 -0
  228. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_create_model.py +0 -0
  229. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_decorators.py +0 -0
  230. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_deprecated_validate_arguments.py +0 -0
  231. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_discriminated_union.py +0 -0
  232. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_docs.py +0 -0
  233. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_errors.py +0 -0
  234. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_exports.py +0 -0
  235. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_fastapi.sh +0 -0
  236. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_fastapi_json_schema.py +0 -0
  237. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_fields.py +0 -0
  238. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_forward_ref.py +0 -0
  239. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_generics.py +0 -0
  240. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_internal.py +0 -0
  241. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_json.py +0 -0
  242. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_migration.py +0 -0
  243. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_model_signature.py +0 -0
  244. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_model_validator.py +0 -0
  245. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_networks.py +0 -0
  246. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_networks_ipaddress.py +0 -0
  247. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_parse.py +0 -0
  248. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_prepare_annotations.py +0 -0
  249. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_private_attributes.py +0 -0
  250. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_pydantic_extra_types.sh +0 -0
  251. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_pydantic_settings.sh +0 -0
  252. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_rich_repr.py +0 -0
  253. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_serialize.py +0 -0
  254. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_strict.py +0 -0
  255. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_structural_pattern_matching.py +0 -0
  256. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_tools.py +0 -0
  257. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_type_adapter.py +0 -0
  258. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_type_alias_type.py +0 -0
  259. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_types.py +0 -0
  260. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_types_namedtuple.py +0 -0
  261. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_types_payment_card_number.py +0 -0
  262. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_types_typeddict.py +0 -0
  263. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_typing.py +0 -0
  264. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_utils.py +0 -0
  265. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_v1.py +0 -0
  266. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_validate_call.py +0 -0
  267. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_validators.py +0 -0
  268. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_validators_dataclass.py +0 -0
  269. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_version.py +0 -0
  270. {pydantic-2.2.0 → pydantic-2.3.0}/tests/test_warnings.py +0 -0
@@ -1,3 +1,33 @@
1
+ ## v2.3.0 (2023-08-23)
2
+
3
+ [GitHub release](https://github.com/pydantic/pydantic/releases/tag/v2.3.0)
4
+
5
+ * 🔥 Remove orphaned changes file from repo by @lig in https://github.com/pydantic/pydantic/pull/7168
6
+ * Add copy button on documentation by @Kludex in https://github.com/pydantic/pydantic/pull/7190
7
+ * Fix docs on JSON type by @Kludex in https://github.com/pydantic/pydantic/pull/7189
8
+ * Update mypy 1.5.0 to 1.5.1 in CI by @hramezani in https://github.com/pydantic/pydantic/pull/7191
9
+ * fix download links badge by @samuelcolvin in https://github.com/pydantic/pydantic/pull/7200
10
+ * add 2.2.1 to changelog by @samuelcolvin in https://github.com/pydantic/pydantic/pull/7212
11
+ * Make ModelWrapValidator protocols generic by @dmontagu in https://github.com/pydantic/pydantic/pull/7154
12
+ * Correct `Field(..., exclude: bool)` docs by @samuelcolvin in https://github.com/pydantic/pydantic/pull/7214
13
+ * Make shadowing attributes a warning instead of an error by @adriangb in https://github.com/pydantic/pydantic/pull/7193
14
+ * Document `Base64Str` and `Base64Bytes` by @Kludex in https://github.com/pydantic/pydantic/pull/7192
15
+ * Fix `config.defer_build` for serialization first cases by @samuelcolvin in https://github.com/pydantic/pydantic/pull/7024
16
+ * clean Model docstrings in JSON Schema by @samuelcolvin in https://github.com/pydantic/pydantic/pull/7210
17
+ * fix #7228 (typo): docs in `validators.md` to correct `validate_default` kwarg by @lmmx in https://github.com/pydantic/pydantic/pull/7229
18
+ * ✅ Implement `tzinfo.fromutc` method for `TzInfo` in `pydantic-core` by @lig in https://github.com/pydantic/pydantic/pull/7019
19
+ * Support `__get_validators__` by @hramezani in https://github.com/pydantic/pydantic/pull/7197
20
+
21
+ ## v2.2.1 (2023-08-18)
22
+
23
+ [GitHub release](https://github.com/pydantic/pydantic/releases/tag/v2.2.1)
24
+
25
+ * Make `xfail`ing test for root model extra stop `xfail`ing by @dmontagu in [#6937](https://github.com/pydantic/pydantic/pull/6937)
26
+ * Optimize recursion detection by stopping on the second visit for the same object by @mciucu in [#7160](https://github.com/pydantic/pydantic/pull/7160)
27
+ * fix link in docs by @tlambert03 in [#7166](https://github.com/pydantic/pydantic/pull/7166)
28
+ * Replace MiMalloc w/ default allocator by @adriangb in [pydantic/pydantic-core#900](https://github.com/pydantic/pydantic-core/pull/900)
29
+ * Bump pydantic-core to 2.6.1 and prepare 2.2.1 release by @adriangb in [#7176](https://github.com/pydantic/pydantic/pull/7176)
30
+
1
31
  ## v2.2.0 (2023-08-17)
2
32
 
3
33
  [GitHub release](https://github.com/pydantic/pydantic/releases/tag/v2.2.0)
@@ -11,6 +11,7 @@ sources = pydantic tests docs/plugins
11
11
 
12
12
  .PHONY: install ## Install the package, dependencies, and pre-commit for local development
13
13
  install: .pdm .pre-commit
14
+ pdm info
14
15
  pdm install --group :all
15
16
  pre-commit install --install-hooks
16
17
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pydantic
3
- Version: 2.2.0
3
+ Version: 2.3.0
4
4
  Summary: Data validation using Python type hints
5
5
  Project-URL: Homepage, https://github.com/pydantic/pydantic
6
6
  Project-URL: Documentation, https://docs.pydantic.dev
@@ -35,7 +35,7 @@ Classifier: Topic :: Internet
35
35
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
36
36
  Requires-Python: >=3.7
37
37
  Requires-Dist: annotated-types>=0.4.0
38
- Requires-Dist: pydantic-core==2.6.0
38
+ Requires-Dist: pydantic-core==2.6.3
39
39
  Requires-Dist: typing-extensions>=4.6.1
40
40
  Provides-Extra: email
41
41
  Requires-Dist: email-validator>=2.0.0; extra == 'email'
@@ -47,7 +47,7 @@ Description-Content-Type: text/markdown
47
47
  [![Coverage](https://coverage-badge.samuelcolvin.workers.dev/pydantic/pydantic.svg)](https://coverage-badge.samuelcolvin.workers.dev/redirect/pydantic/pydantic)
48
48
  [![pypi](https://img.shields.io/pypi/v/pydantic.svg)](https://pypi.python.org/pypi/pydantic)
49
49
  [![CondaForge](https://img.shields.io/conda/v/conda-forge/pydantic.svg)](https://anaconda.org/conda-forge/pydantic)
50
- [![downloads](https://pepy.tech/badge/pydantic/month)](https://pepy.tech/project/pydantic)
50
+ [![downloads](https://static.pepy.tech/badge/pydantic/month)](https://pepy.tech/project/pydantic)
51
51
  [![versions](https://img.shields.io/pypi/pyversions/pydantic.svg)](https://github.com/pydantic/pydantic)
52
52
  [![license](https://img.shields.io/github/license/pydantic/pydantic.svg)](https://github.com/pydantic/pydantic/blob/main/LICENSE)
53
53
  [![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://docs.pydantic.dev/latest/contributing/#badges)
@@ -113,6 +113,36 @@ See our [security policy](https://github.com/pydantic/pydantic/security/policy).
113
113
 
114
114
  ## Changelog
115
115
 
116
+ ## v2.3.0 (2023-08-23)
117
+
118
+ [GitHub release](https://github.com/pydantic/pydantic/releases/tag/v2.3.0)
119
+
120
+ * 🔥 Remove orphaned changes file from repo by [@lig](https://github.com/lig) in https://github.com/pydantic/pydantic/pull/7168
121
+ * Add copy button on documentation by [@Kludex](https://github.com/Kludex) in https://github.com/pydantic/pydantic/pull/7190
122
+ * Fix docs on JSON type by [@Kludex](https://github.com/Kludex) in https://github.com/pydantic/pydantic/pull/7189
123
+ * Update mypy 1.5.0 to 1.5.1 in CI by [@hramezani](https://github.com/hramezani) in https://github.com/pydantic/pydantic/pull/7191
124
+ * fix download links badge by [@samuelcolvin](https://github.com/samuelcolvin) in https://github.com/pydantic/pydantic/pull/7200
125
+ * add 2.2.1 to changelog by [@samuelcolvin](https://github.com/samuelcolvin) in https://github.com/pydantic/pydantic/pull/7212
126
+ * Make ModelWrapValidator protocols generic by [@dmontagu](https://github.com/dmontagu) in https://github.com/pydantic/pydantic/pull/7154
127
+ * Correct `Field(..., exclude: bool)` docs by [@samuelcolvin](https://github.com/samuelcolvin) in https://github.com/pydantic/pydantic/pull/7214
128
+ * Make shadowing attributes a warning instead of an error by [@adriangb](https://github.com/adriangb) in https://github.com/pydantic/pydantic/pull/7193
129
+ * Document `Base64Str` and `Base64Bytes` by [@Kludex](https://github.com/Kludex) in https://github.com/pydantic/pydantic/pull/7192
130
+ * Fix `config.defer_build` for serialization first cases by [@samuelcolvin](https://github.com/samuelcolvin) in https://github.com/pydantic/pydantic/pull/7024
131
+ * clean Model docstrings in JSON Schema by [@samuelcolvin](https://github.com/samuelcolvin) in https://github.com/pydantic/pydantic/pull/7210
132
+ * fix [#7228](https://github.com/pydantic/pydantic/issues/7228) (typo): docs in `validators.md` to correct `validate_default` kwarg by [@lmmx](https://github.com/lmmx) in https://github.com/pydantic/pydantic/pull/7229
133
+ * ✅ Implement `tzinfo.fromutc` method for `TzInfo` in `pydantic-core` by [@lig](https://github.com/lig) in https://github.com/pydantic/pydantic/pull/7019
134
+ * Support `__get_validators__` by [@hramezani](https://github.com/hramezani) in https://github.com/pydantic/pydantic/pull/7197
135
+
136
+ ## v2.2.1 (2023-08-18)
137
+
138
+ [GitHub release](https://github.com/pydantic/pydantic/releases/tag/v2.2.1)
139
+
140
+ * Make `xfail`ing test for root model extra stop `xfail`ing by [@dmontagu](https://github.com/dmontagu) in [#6937](https://github.com/pydantic/pydantic/pull/6937)
141
+ * Optimize recursion detection by stopping on the second visit for the same object by [@mciucu](https://github.com/mciucu) in [#7160](https://github.com/pydantic/pydantic/pull/7160)
142
+ * fix link in docs by [@tlambert03](https://github.com/tlambert03) in [#7166](https://github.com/pydantic/pydantic/pull/7166)
143
+ * Replace MiMalloc w/ default allocator by [@adriangb](https://github.com/adriangb) in [pydantic/pydantic-core#900](https://github.com/pydantic/pydantic-core/pull/900)
144
+ * Bump pydantic-core to 2.6.1 and prepare 2.2.1 release by [@adriangb](https://github.com/adriangb) in [#7176](https://github.com/pydantic/pydantic/pull/7176)
145
+
116
146
  ## v2.2.0 (2023-08-17)
117
147
 
118
148
  [GitHub release](https://github.com/pydantic/pydantic/releases/tag/v2.2.0)
@@ -4,7 +4,7 @@
4
4
  [![Coverage](https://coverage-badge.samuelcolvin.workers.dev/pydantic/pydantic.svg)](https://coverage-badge.samuelcolvin.workers.dev/redirect/pydantic/pydantic)
5
5
  [![pypi](https://img.shields.io/pypi/v/pydantic.svg)](https://pypi.python.org/pypi/pydantic)
6
6
  [![CondaForge](https://img.shields.io/conda/v/conda-forge/pydantic.svg)](https://anaconda.org/conda-forge/pydantic)
7
- [![downloads](https://pepy.tech/badge/pydantic/month)](https://pepy.tech/project/pydantic)
7
+ [![downloads](https://static.pepy.tech/badge/pydantic/month)](https://pepy.tech/project/pydantic)
8
8
  [![versions](https://img.shields.io/pypi/pyversions/pydantic.svg)](https://github.com/pydantic/pydantic)
9
9
  [![license](https://img.shields.io/github/license/pydantic/pydantic.svg)](https://github.com/pydantic/pydantic/blob/main/LICENSE)
10
10
  [![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://docs.pydantic.dev/latest/contributing/#badges)
@@ -467,8 +467,12 @@ def _simplify_schema_references(schema: core_schema.CoreSchema, inline: bool) ->
467
467
  return recurse(s, count_refs)
468
468
  ref = s['schema_ref']
469
469
  ref_counts[ref] += 1
470
- if current_recursion_ref_count[ref] != 0:
471
- involved_in_recursion[ref] = True
470
+
471
+ if ref_counts[ref] >= 2:
472
+ # If this model is involved in a recursion this should be detected
473
+ # on its second encounter, we can safely stop the walk here.
474
+ if current_recursion_ref_count[ref] != 0:
475
+ involved_in_recursion[ref] = True
472
476
  return s
473
477
 
474
478
  current_recursion_ref_count[ref] += 1
@@ -20,7 +20,7 @@ from ._core_utils import collect_invalid_schemas, flatten_schema_defs, inline_sc
20
20
  from ._fields import collect_dataclass_fields
21
21
  from ._generate_schema import GenerateSchema
22
22
  from ._generics import get_standard_typevars_map
23
- from ._mock_validator import set_dataclass_mock_validator
23
+ from ._mock_val_ser import set_dataclass_mock_validator
24
24
  from ._schema_generation_shared import CallbackGetCoreSchemaHandler
25
25
 
26
26
  if typing.TYPE_CHECKING:
@@ -151,9 +151,9 @@ def collect_model_fields( # noqa: C901
151
151
  if base is generic_origin:
152
152
  # Don't error when "shadowing" of attributes in parametrized generics
153
153
  continue
154
- raise NameError(
155
- f'Field name "{ann_name}" shadows an attribute in parent "{base.__qualname__}"; '
156
- f'you might want to use a different field name with "alias=\'{ann_name}\'".'
154
+ warnings.warn(
155
+ f'Field name "{ann_name}" shadows an attribute in parent "{base.__qualname__}"; ',
156
+ UserWarning,
157
157
  )
158
158
 
159
159
  try:
@@ -219,7 +219,7 @@ def modify_model_json_schema(
219
219
  original_schema['title'] = cls.__name__
220
220
  docstring = cls.__doc__
221
221
  if docstring and 'description' not in original_schema:
222
- original_schema['description'] = docstring
222
+ original_schema['description'] = inspect.cleandoc(docstring)
223
223
  return json_schema
224
224
 
225
225
 
@@ -587,16 +587,25 @@ class GenerateSchema:
587
587
  else:
588
588
  ref_mode = 'to-def'
589
589
 
590
+ schema: CoreSchema
590
591
  get_schema = getattr(obj, '__get_pydantic_core_schema__', None)
591
592
  if get_schema is None:
592
- return None
593
-
594
- schema: CoreSchema
595
- if len(inspect.signature(get_schema).parameters) == 1:
596
- # (source) -> CoreSchema
597
- schema = get_schema(source)
593
+ validators = getattr(obj, '__get_validators__', None)
594
+ if validators is None:
595
+ return None
596
+ warn(
597
+ '`__get_validators__` is deprecated and will be removed, use `__get_pydantic_core_schema__` instead.',
598
+ PydanticDeprecatedSince20,
599
+ )
600
+ schema = core_schema.chain_schema([core_schema.general_plain_validator_function(v) for v in validators()])
598
601
  else:
599
- schema = get_schema(source, CallbackGetCoreSchemaHandler(self._generate_schema, self, ref_mode=ref_mode))
602
+ if len(inspect.signature(get_schema).parameters) == 1:
603
+ # (source) -> CoreSchema
604
+ schema = get_schema(source)
605
+ else:
606
+ schema = get_schema(
607
+ source, CallbackGetCoreSchemaHandler(self._generate_schema, self, ref_mode=ref_mode)
608
+ )
600
609
 
601
610
  schema = self._unpack_refs_defs(schema)
602
611
 
@@ -0,0 +1,118 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Callable, Generic, TypeVar
4
+
5
+ from pydantic_core import SchemaSerializer, SchemaValidator
6
+ from typing_extensions import Literal
7
+
8
+ from ..errors import PydanticErrorCodes, PydanticUserError
9
+
10
+ if TYPE_CHECKING:
11
+ from ..dataclasses import PydanticDataclass
12
+ from ..main import BaseModel
13
+
14
+
15
+ ValSer = TypeVar('ValSer', SchemaValidator, SchemaSerializer)
16
+
17
+
18
+ class MockValSer(Generic[ValSer]):
19
+ """Mocker for `pydantic_core.SchemaValidator` or `pydantic_core.SchemaSerializer` which optionally attempts to
20
+ rebuild the thing it's mocking when one of its methods is accessed and raises an error if that fails.
21
+ """
22
+
23
+ __slots__ = '_error_message', '_code', '_val_or_ser', '_attempt_rebuild'
24
+
25
+ def __init__(
26
+ self,
27
+ error_message: str,
28
+ *,
29
+ code: PydanticErrorCodes,
30
+ val_or_ser: Literal['validator', 'serializer'],
31
+ attempt_rebuild: Callable[[], ValSer | None] | None = None,
32
+ ) -> None:
33
+ self._error_message = error_message
34
+ self._val_or_ser = SchemaValidator if val_or_ser == 'validator' else SchemaSerializer
35
+ self._code: PydanticErrorCodes = code
36
+ self._attempt_rebuild = attempt_rebuild
37
+
38
+ def __getattr__(self, item: str) -> None:
39
+ __tracebackhide__ = True
40
+ if self._attempt_rebuild:
41
+ val_ser = self._attempt_rebuild()
42
+ if val_ser is not None:
43
+ return getattr(val_ser, item)
44
+
45
+ # raise an AttributeError if `item` doesn't exist
46
+ getattr(self._val_or_ser, item)
47
+ raise PydanticUserError(self._error_message, code=self._code)
48
+
49
+ def rebuild(self) -> ValSer | None:
50
+ if self._attempt_rebuild:
51
+ val_ser = self._attempt_rebuild()
52
+ if val_ser is not None:
53
+ return val_ser
54
+ else:
55
+ raise PydanticUserError(self._error_message, code=self._code)
56
+ return None
57
+
58
+
59
+ def set_model_mocks(cls: type[BaseModel], cls_name: str, undefined_name: str = 'all referenced types') -> None:
60
+ """Set `__pydantic_validator__` and `__pydantic_serializer__` to `MockValSer`s on a model.
61
+
62
+ Args:
63
+ cls: The model class to set the mocks on
64
+ cls_name: Name of the model class, used in error messages
65
+ undefined_name: Name of the undefined thing, used in error messages
66
+ """
67
+ undefined_type_error_message = (
68
+ f'`{cls_name}` is not fully defined; you should define {undefined_name},'
69
+ f' then call `{cls_name}.model_rebuild()`.'
70
+ )
71
+
72
+ def attempt_rebuild_validator() -> SchemaValidator | None:
73
+ if cls.model_rebuild(raise_errors=False, _parent_namespace_depth=5):
74
+ return cls.__pydantic_validator__
75
+ else:
76
+ return None
77
+
78
+ cls.__pydantic_validator__ = MockValSer( # type: ignore[assignment]
79
+ undefined_type_error_message,
80
+ code='class-not-fully-defined',
81
+ val_or_ser='validator',
82
+ attempt_rebuild=attempt_rebuild_validator,
83
+ )
84
+
85
+ def attempt_rebuild_serializer() -> SchemaSerializer | None:
86
+ if cls.model_rebuild(raise_errors=False, _parent_namespace_depth=5):
87
+ return cls.__pydantic_serializer__
88
+ else:
89
+ return None
90
+
91
+ cls.__pydantic_serializer__ = MockValSer( # type: ignore[assignment]
92
+ undefined_type_error_message,
93
+ code='class-not-fully-defined',
94
+ val_or_ser='serializer',
95
+ attempt_rebuild=attempt_rebuild_serializer,
96
+ )
97
+
98
+
99
+ def set_dataclass_mock_validator(cls: type[PydanticDataclass], cls_name: str, undefined_name: str) -> None:
100
+ undefined_type_error_message = (
101
+ f'`{cls_name}` is not fully defined; you should define {undefined_name},'
102
+ f' then call `pydantic.dataclasses.rebuild_dataclass({cls_name})`.'
103
+ )
104
+
105
+ def attempt_rebuild() -> SchemaValidator | None:
106
+ from ..dataclasses import rebuild_dataclass
107
+
108
+ if rebuild_dataclass(cls, raise_errors=False, _parent_namespace_depth=5):
109
+ return cls.__pydantic_validator__
110
+ else:
111
+ return None
112
+
113
+ cls.__pydantic_validator__ = MockValSer( # type: ignore[assignment]
114
+ undefined_type_error_message,
115
+ code='class-not-fully-defined',
116
+ val_or_ser='validator',
117
+ attempt_rebuild=attempt_rebuild,
118
+ )
@@ -22,7 +22,7 @@ from ._discriminated_union import apply_discriminators
22
22
  from ._fields import collect_model_fields, is_valid_field_name, is_valid_privateattr_name
23
23
  from ._generate_schema import GenerateSchema
24
24
  from ._generics import PydanticGenericMetadata, get_model_typevars_map
25
- from ._mock_validator import MockValidator, set_basemodel_mock_validator
25
+ from ._mock_val_ser import MockValSer, set_model_mocks
26
26
  from ._schema_generation_shared import CallbackGetCoreSchemaHandler
27
27
  from ._typing_extra import get_cls_types_namespace, is_classvar, parent_frame_namespace
28
28
  from ._utils import ClassAttribute, is_valid_identifier
@@ -202,7 +202,7 @@ class ModelMetaclass(ABCMeta):
202
202
  if item == '__pydantic_core_schema__':
203
203
  # This means the class didn't get a schema generated for it, likely because there was an undefined reference
204
204
  maybe_mock_validator = getattr(self, '__pydantic_validator__', None)
205
- if isinstance(maybe_mock_validator, MockValidator):
205
+ if isinstance(maybe_mock_validator, MockValSer):
206
206
  rebuilt_validator = maybe_mock_validator.rebuild()
207
207
  if rebuilt_validator is not None:
208
208
  # In this case, a validator was built, and so `__pydantic_core_schema__` should now be set
@@ -461,7 +461,7 @@ def complete_model_class(
461
461
  )
462
462
 
463
463
  if config_wrapper.defer_build:
464
- set_basemodel_mock_validator(cls, cls_name)
464
+ set_model_mocks(cls, cls_name)
465
465
  return False
466
466
 
467
467
  try:
@@ -469,7 +469,7 @@ def complete_model_class(
469
469
  except PydanticUndefinedAnnotation as e:
470
470
  if raise_errors:
471
471
  raise
472
- set_basemodel_mock_validator(cls, cls_name, f'`{e.name}`')
472
+ set_model_mocks(cls, cls_name, f'`{e.name}`')
473
473
  return False
474
474
 
475
475
  core_config = config_wrapper.core_config(cls)
@@ -477,7 +477,7 @@ def complete_model_class(
477
477
  schema = gen_schema.collect_definitions(schema)
478
478
  schema = apply_discriminators(flatten_schema_defs(schema))
479
479
  if collect_invalid_schemas(schema):
480
- set_basemodel_mock_validator(cls, cls_name)
480
+ set_model_mocks(cls, cls_name)
481
481
  return False
482
482
 
483
483
  # debug(schema)
@@ -56,6 +56,7 @@ PydanticErrorCodes = Literal[
56
56
  'multiple-field-serializers',
57
57
  'invalid_annotated_type',
58
58
  'type-adapter-config-unused',
59
+ 'root-model-extra',
59
60
  ]
60
61
 
61
62
 
@@ -351,7 +351,7 @@ class ModelWrapValidatorHandler(_core_schema.ValidatorFunctionWrapHandler, Proto
351
351
  ...
352
352
 
353
353
 
354
- class ModelWrapValidatorWithoutInfo(Protocol):
354
+ class ModelWrapValidatorWithoutInfo(Protocol[_ModelType]):
355
355
  """A @model_validator decorated function signature.
356
356
  This is used when `mode='wrap'` and the function does not have info argument.
357
357
  """
@@ -368,7 +368,7 @@ class ModelWrapValidatorWithoutInfo(Protocol):
368
368
  ...
369
369
 
370
370
 
371
- class ModelWrapValidator(Protocol):
371
+ class ModelWrapValidator(Protocol[_ModelType]):
372
372
  """A @model_validator decorated function signature. This is used when `mode='wrap'`."""
373
373
 
374
374
  def __call__( # noqa: D102
@@ -423,7 +423,7 @@ have info argument.
423
423
  ModelAfterValidator = Callable[[_ModelType, _core_schema.ValidationInfo], _ModelType]
424
424
  """A `@model_validator` decorated function signature. This is used when `mode='after'`."""
425
425
 
426
- _AnyModelWrapValidator = Union[ModelWrapValidator, ModelWrapValidatorWithoutInfo]
426
+ _AnyModelWrapValidator = Union[ModelWrapValidator[_ModelType], ModelWrapValidatorWithoutInfo[_ModelType]]
427
427
  _AnyModeBeforeValidator = Union[ModelBeforeValidator, ModelBeforeValidatorWithoutInfo]
428
428
  _AnyModelAfterValidator = Union[ModelAfterValidator[_ModelType], ModelAfterValidatorWithoutInfo[_ModelType]]
429
429
 
@@ -41,7 +41,7 @@ from typing_extensions import Annotated, Literal, assert_never
41
41
 
42
42
  from pydantic._internal import _annotated_handlers, _internal_dataclass
43
43
 
44
- from ._internal import _core_metadata, _core_utils, _mock_validator, _schema_generation_shared, _typing_extra
44
+ from ._internal import _core_metadata, _core_utils, _mock_val_ser, _schema_generation_shared, _typing_extra
45
45
  from .config import JsonSchemaExtraCallable
46
46
  from .errors import PydanticInvalidForJsonSchema, PydanticUserError
47
47
 
@@ -2119,7 +2119,7 @@ def model_json_schema(
2119
2119
  The generated JSON Schema.
2120
2120
  """
2121
2121
  schema_generator_instance = schema_generator(by_alias=by_alias, ref_template=ref_template)
2122
- if isinstance(cls.__pydantic_validator__, _mock_validator.MockValidator):
2122
+ if isinstance(cls.__pydantic_validator__, _mock_val_ser.MockValSer):
2123
2123
  cls.__pydantic_validator__.rebuild()
2124
2124
  assert '__pydantic_core_schema__' in cls.__dict__, 'this is a bug! please report it'
2125
2125
  return schema_generator_instance.generate(cls.__pydantic_core_schema__, mode=mode)
@@ -18,7 +18,7 @@ from ._internal import (
18
18
  _fields,
19
19
  _forward_ref,
20
20
  _generics,
21
- _mock_validator,
21
+ _mock_val_ser,
22
22
  _model_construction,
23
23
  _repr,
24
24
  _typing_extra,
@@ -134,8 +134,14 @@ class BaseModel(metaclass=_model_construction.ModelMetaclass):
134
134
  model_fields = {}
135
135
  __pydantic_decorators__ = _decorators.DecoratorInfos()
136
136
  # Prevent `BaseModel` from being instantiated directly:
137
- __pydantic_validator__ = _mock_validator.MockValidator(
137
+ __pydantic_validator__ = _mock_val_ser.MockValSer(
138
138
  'Pydantic models should inherit from BaseModel, BaseModel cannot be instantiated directly',
139
+ val_or_ser='validator',
140
+ code='base-model-instantiated',
141
+ )
142
+ __pydantic_serializer__ = _mock_val_ser.MockValSer(
143
+ 'Pydantic models should inherit from BaseModel, BaseModel cannot be instantiated directly',
144
+ val_or_ser='serializer',
139
145
  code='base-model-instantiated',
140
146
  )
141
147
 
@@ -240,7 +246,9 @@ class BaseModel(metaclass=_model_construction.ModelMetaclass):
240
246
  return m
241
247
 
242
248
  def model_copy(self: Model, *, update: dict[str, Any] | None = None, deep: bool = False) -> Model:
243
- """Returns a copy of the model.
249
+ """Usage docs: https://docs.pydantic.dev/2.2/usage/serialization/#model_copy
250
+
251
+ Returns a copy of the model.
244
252
 
245
253
  Args:
246
254
  update: Values to change/add in the new model. Note: the data is not validated
@@ -7,6 +7,7 @@ from copy import copy, deepcopy
7
7
 
8
8
  from pydantic_core import PydanticUndefined
9
9
 
10
+ from . import PydanticUserError
10
11
  from ._internal import _repr
11
12
  from .main import BaseModel, _object_setattr
12
13
 
@@ -43,6 +44,14 @@ class RootModel(BaseModel, typing.Generic[RootModelRootType]):
43
44
 
44
45
  root: RootModelRootType
45
46
 
47
+ def __init_subclass__(cls, **kwargs):
48
+ extra = cls.model_config.get('extra')
49
+ if extra is not None:
50
+ raise PydanticUserError(
51
+ "`RootModel` does not support setting `model_config['extra']`", code='root-model-extra'
52
+ )
53
+ super().__init_subclass__(**kwargs)
54
+
46
55
  def __init__(__pydantic_self__, root: RootModelRootType = PydanticUndefined, **data) -> None: # type: ignore
47
56
  __tracebackhide__ = True
48
57
  if data:
@@ -1356,7 +1356,9 @@ class EncodedStr(EncodedBytes):
1356
1356
 
1357
1357
 
1358
1358
  Base64Bytes = Annotated[bytes, EncodedBytes(encoder=Base64Encoder)]
1359
+ """A bytes type that is encoded and decoded using the base64 encoder."""
1359
1360
  Base64Str = Annotated[str, EncodedStr(encoder=Base64Encoder)]
1361
+ """A str type that is encoded and decoded using the base64 encoder."""
1360
1362
 
1361
1363
 
1362
1364
  __getattr__ = getattr_migration(__name__)
@@ -3,7 +3,7 @@ from typing import Tuple
3
3
 
4
4
  __all__ = 'VERSION', 'version_info'
5
5
 
6
- VERSION = '2.2.0'
6
+ VERSION = '2.3.0'
7
7
  """The version of Pydantic."""
8
8
 
9
9
 
@@ -61,7 +61,7 @@ requires-python = '>=3.7'
61
61
  dependencies = [
62
62
  'typing-extensions>=4.6.1',
63
63
  'annotated-types>=0.4.0',
64
- "pydantic-core==2.6.0",
64
+ "pydantic-core==2.6.3",
65
65
  ]
66
66
  dynamic = ['version', 'readme']
67
67
 
@@ -4,10 +4,10 @@ import sys
4
4
  from contextlib import nullcontext as does_not_raise
5
5
  from decimal import Decimal
6
6
  from inspect import signature
7
- from typing import Any, ContextManager, Iterable, NamedTuple, Type, Union, get_type_hints
7
+ from typing import Any, ContextManager, Iterable, NamedTuple, Optional, Type, Union, get_type_hints
8
8
 
9
9
  from dirty_equals import HasRepr, IsPartialDict
10
- from pydantic_core import SchemaError, SchemaValidator
10
+ from pydantic_core import SchemaError, SchemaSerializer, SchemaValidator
11
11
 
12
12
  from pydantic import (
13
13
  BaseConfig,
@@ -22,10 +22,11 @@ from pydantic import (
22
22
  validate_call,
23
23
  )
24
24
  from pydantic._internal._config import ConfigWrapper, config_defaults
25
- from pydantic._internal._mock_validator import MockValidator
25
+ from pydantic._internal._mock_val_ser import MockValSer
26
26
  from pydantic.config import ConfigDict
27
27
  from pydantic.dataclasses import dataclass as pydantic_dataclass
28
28
  from pydantic.errors import PydanticUserError
29
+ from pydantic.fields import FieldInfo
29
30
  from pydantic.type_adapter import TypeAdapter
30
31
  from pydantic.warnings import PydanticDeprecationWarning
31
32
 
@@ -676,12 +677,14 @@ def test_config_model_defer_build():
676
677
  class MyModel(BaseModel, defer_build=True):
677
678
  x: int
678
679
 
679
- assert isinstance(MyModel.__pydantic_validator__, MockValidator)
680
+ assert isinstance(MyModel.__pydantic_validator__, MockValSer)
681
+ assert isinstance(MyModel.__pydantic_serializer__, MockValSer)
680
682
 
681
683
  m = MyModel(x=1)
682
684
  assert m.x == 1
683
685
 
684
686
  assert isinstance(MyModel.__pydantic_validator__, SchemaValidator)
687
+ assert isinstance(MyModel.__pydantic_serializer__, SchemaSerializer)
685
688
 
686
689
 
687
690
  def test_config_model_defer_build_nested():
@@ -691,9 +694,58 @@ def test_config_model_defer_build_nested():
691
694
  class MyModel(BaseModel):
692
695
  y: MyNestedModel
693
696
 
694
- assert isinstance(MyNestedModel.__pydantic_validator__, MockValidator)
697
+ assert isinstance(MyNestedModel.__pydantic_validator__, MockValSer)
698
+ assert isinstance(MyNestedModel.__pydantic_serializer__, MockValSer)
695
699
 
696
700
  m = MyModel(y={'x': 1})
697
701
  assert m.model_dump() == {'y': {'x': 1}}
698
702
 
699
- assert isinstance(MyNestedModel.__pydantic_validator__, MockValidator)
703
+ assert isinstance(MyNestedModel.__pydantic_validator__, MockValSer)
704
+ assert isinstance(MyNestedModel.__pydantic_serializer__, MockValSer)
705
+
706
+
707
+ def test_config_model_defer_build_ser_first():
708
+ class M1(BaseModel, defer_build=True):
709
+ a: str
710
+
711
+ class M2(BaseModel, defer_build=True):
712
+ b: M1
713
+
714
+ m = M2.model_validate({'b': {'a': 'foo'}})
715
+ assert m.b.model_dump() == {'a': 'foo'}
716
+
717
+
718
+ def test_defer_build_json_schema():
719
+ class M(BaseModel, defer_build=True):
720
+ a: int
721
+
722
+ assert M.model_json_schema() == {
723
+ 'title': 'M',
724
+ 'type': 'object',
725
+ 'properties': {'a': {'title': 'A', 'type': 'integer'}},
726
+ 'required': ['a'],
727
+ }
728
+
729
+
730
+ def test_partial_creation_with_defer_build():
731
+ class M(BaseModel):
732
+ a: int
733
+ b: int
734
+
735
+ def create_partial(model, optionals):
736
+ override_fields = {}
737
+ model.model_rebuild()
738
+ for name, field in model.model_fields.items():
739
+ if field.is_required() and name in optionals:
740
+ assert field.annotation is not None
741
+ override_fields[name] = (Optional[field.annotation], FieldInfo.merge_field_infos(field, default=None))
742
+
743
+ return create_model(f'Partial{model.__name__}', __base__=model, **override_fields)
744
+
745
+ partial = create_partial(M, {'a'})
746
+
747
+ # Comment this away and the last assertion works
748
+ assert M.model_json_schema()['required'] == ['a', 'b']
749
+
750
+ # AssertionError: assert ['a', 'b'] == ['b']
751
+ assert partial.model_json_schema()['required'] == ['b']
@@ -32,7 +32,7 @@ from pydantic import (
32
32
  field_validator,
33
33
  model_validator,
34
34
  )
35
- from pydantic._internal._mock_validator import MockValidator
35
+ from pydantic._internal._mock_val_ser import MockValSer
36
36
  from pydantic.dataclasses import rebuild_dataclass
37
37
  from pydantic.fields import Field, FieldInfo
38
38
  from pydantic.json_schema import model_json_schema
@@ -1530,8 +1530,8 @@ def test_cyclic_reference_dataclass(create_module):
1530
1530
  D2 = module.D2
1531
1531
 
1532
1532
  # Confirm D1 and D2 require rebuilding
1533
- assert isinstance(D1.__pydantic_validator__, MockValidator)
1534
- assert isinstance(D2.__pydantic_validator__, MockValidator)
1533
+ assert isinstance(D1.__pydantic_validator__, MockValSer)
1534
+ assert isinstance(D2.__pydantic_validator__, MockValSer)
1535
1535
 
1536
1536
  # Note: the rebuilds of D1 and D2 happen automatically, and works since it grabs the locals here as the namespace,
1537
1537
  # which contains D1 and D2
@@ -1597,7 +1597,7 @@ def test_cross_module_cyclic_reference_dataclass(create_module):
1597
1597
  rebuild_dataclass(D1, _types_namespace={'D2': module.D2, 'D1': D1})
1598
1598
 
1599
1599
  # Confirm D2 still requires a rebuild (it will happen automatically)
1600
- assert isinstance(module.D2.__pydantic_validator__, MockValidator)
1600
+ assert isinstance(module.D2.__pydantic_validator__, MockValSer)
1601
1601
 
1602
1602
  instance = D1(d2=module.D2(d1=D1(d2=module.D2(d1=D1()))))
1603
1603