pydantic 2.4.0__tar.gz → 2.4.2__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.
- {pydantic-2.4.0 → pydantic-2.4.2}/HISTORY.md +40 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/PKG-INFO +42 -2
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_core_utils.py +60 -111
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_discriminated_union.py +11 -2
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_generate_schema.py +30 -26
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_repr.py +4 -1
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/json_schema.py +4 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/datetime_parse.py +1 -1
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/fields.py +1 -1
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/main.py +3 -3
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/networks.py +8 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/version.py +1 -1
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/version.py +1 -1
- {pydantic-2.4.0 → pydantic-2.4.2}/pyproject.toml +9 -9
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_discriminated_union.py +52 -35
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_edge_cases.py +92 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_generics.py +149 -1
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_json_schema.py +83 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_model_signature.py +0 -1
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_types.py +6 -6
- {pydantic-2.4.0 → pydantic-2.4.2}/.gitignore +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/LICENSE +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/Makefile +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/README.md +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/__init__.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/__init__.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_config.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_core_metadata.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_dataclasses.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_decorators.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_decorators_v1.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_fields.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_forward_ref.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_generics.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_internal_dataclass.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_known_annotated_metadata.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_mock_val_ser.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_model_construction.py +2 -2
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_schema_generation_shared.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_std_types_schema.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_typing_extra.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_utils.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_validate_call.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_internal/_validators.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/_migration.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/alias_generators.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/annotated_handlers.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/class_validators.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/color.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/config.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/dataclasses.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/datetime_parse.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/decorator.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/deprecated/__init__.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/deprecated/class_validators.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/deprecated/config.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/deprecated/copy_internals.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/deprecated/decorator.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/deprecated/json.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/deprecated/parse.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/deprecated/tools.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/env_settings.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/error_wrappers.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/errors.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/fields.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/functional_serializers.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/functional_validators.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/generics.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/json.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/main.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/mypy.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/networks.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/parse.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/plugin/__init__.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/plugin/_loader.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/plugin/_schema_validator.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/py.typed +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/root_model.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/schema.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/tools.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/type_adapter.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/types.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/typing.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/utils.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/__init__.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/_hypothesis_plugin.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/annotated_types.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/class_validators.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/color.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/config.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/dataclasses.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/decorator.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/env_settings.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/error_wrappers.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/errors.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/generics.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/json.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/mypy.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/parse.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/py.typed +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/schema.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/tools.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/types.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/typing.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/utils.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/v1/validators.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/validate_call.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/validators.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/pydantic/warnings.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/__init__.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/benchmarks/__init__.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/benchmarks/generate_north_star_data.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/benchmarks/test_fastapi_startup_generics.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/benchmarks/test_fastapi_startup_simple.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/benchmarks/test_north_star.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/check_usage_docs.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/conftest.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/__init__.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/configs/mypy-default.ini +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/configs/mypy-plugin-strict-no-any.ini +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/configs/mypy-plugin-strict.ini +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/configs/mypy-plugin-very-strict.ini +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/configs/mypy-plugin.ini +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/configs/pyproject-default.toml +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/configs/pyproject-plugin-bad-param.toml +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/configs/pyproject-plugin-strict.toml +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/configs/pyproject-plugin.toml +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/computed_fields.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/custom_constructor.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/dataclass_no_any.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/fail1.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/fail2.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/fail3.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/fail4.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/fail_defaults.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/generics.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/metaclass_args.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/plugin_default_factory.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/plugin_success.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/plugin_success_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/pydantic_settings.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/modules/success.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-default_ini/fail1.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-default_ini/fail2.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-default_ini/fail3.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-default_ini/fail4.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-default_ini/metaclass_args.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-default_ini/plugin_success.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-default_ini/plugin_success_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-default_ini/pydantic_settings.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-default_ini/success.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin-strict-no-any_ini/dataclass_no_any.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin-strict_ini/fail_defaults.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin-strict_ini/plugin_default_factory.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin-strict_ini/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin-strict_ini/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin-strict_ini/plugin_success.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin-strict_ini/plugin_success_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin-very-strict_ini/metaclass_args.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/custom_constructor.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/generics.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/plugin_success.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/plugin_success_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/mypy-plugin_ini/pydantic_settings.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-default_toml/computed_fields.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-default_toml/fail1.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-default_toml/fail2.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-default_toml/fail3.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-default_toml/fail4.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-default_toml/pydantic_settings.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-default_toml/success.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-plugin-strict_toml/fail_defaults.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-plugin-strict_toml/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-plugin-strict_toml/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-plugin-strict_toml/plugin_success.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-plugin-strict_toml/plugin_success_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-plugin_toml/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-plugin_toml/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-plugin_toml/plugin_success.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-plugin_toml/plugin_success_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.0.1/pyproject-plugin_toml/pydantic_settings.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.1.1/mypy-default_ini/fail1.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.1.1/mypy-default_ini/fail2.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.1.1/mypy-default_ini/metaclass_args.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.1.1/mypy-default_ini/plugin_success.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.1.1/mypy-default_ini/plugin_success_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.1.1/mypy-default_ini/pydantic_settings.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.1.1/pyproject-default_toml/fail1.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.1.1/pyproject-default_toml/fail2.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.1.1/pyproject-default_toml/pydantic_settings.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.2.0/mypy-default_ini/plugin_success.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.2.0/mypy-default_ini/plugin_success_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.2.0/mypy-plugin-strict_ini/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.2.0/mypy-plugin-strict_ini/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.2.0/mypy-plugin_ini/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.2.0/mypy-plugin_ini/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.2.0/pyproject-plugin-strict_toml/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.2.0/pyproject-plugin-strict_toml/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.2.0/pyproject-plugin_toml/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.2.0/pyproject-plugin_toml/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/mypy-default_ini/fail4.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/mypy-default_ini/plugin_success.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/mypy-plugin-strict_ini/plugin_default_factory.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/mypy-plugin-strict_ini/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/mypy-plugin-strict_ini/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/mypy-plugin_ini/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/mypy-plugin_ini/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/mypy-plugin_ini/pydantic_settings.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/pyproject-default_toml/fail4.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/pyproject-plugin-strict_toml/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/pyproject-plugin-strict_toml/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/pyproject-plugin_toml/plugin_fail.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/pyproject-plugin_toml/plugin_fail_baseConfig.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/outputs/1.4.1/pyproject-plugin_toml/pydantic_settings.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/mypy/test_mypy.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/plugin/example_plugin.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/plugin/pyproject.toml +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/plugin/test_plugin.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/pyright/pyproject.toml +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/pyright/pyright_example.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_abc.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_aliases.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_annotated.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_assert_in_validators.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_callable.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_color.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_computed_fields.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_config.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_construction.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_create_model.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_dataclasses.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_datetime.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_decorators.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_deprecated.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_deprecated_validate_arguments.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_docs.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_errors.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_exports.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_fastapi.sh +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_fastapi_changes.patch +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_fastapi_json_schema.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_fields.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_forward_ref.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_internal.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_json.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_main.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_migration.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_model_validator.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_networks.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_networks_ipaddress.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_parse.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_plugins.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_private_attributes.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_pydantic_extra_types.sh +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_pydantic_settings.sh +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_rich_repr.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_root_model.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_serialize.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_strict.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_structural_pattern_matching.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_tools.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_type_adapter.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_type_alias_type.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_types_namedtuple.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_types_payment_card_number.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_types_typeddict.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_typing.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_utils.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_v1.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_validate_call.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_validators.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_validators_dataclass.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_version.py +0 -0
- {pydantic-2.4.0 → pydantic-2.4.2}/tests/test_warnings.py +0 -0
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
## v2.4.2 (2023-09-27)
|
|
2
|
+
|
|
3
|
+
[GitHub release](https://github.com/pydantic/pydantic/releases/tag/v2.4.2)
|
|
4
|
+
|
|
5
|
+
### What's Changed
|
|
6
|
+
|
|
7
|
+
#### Fixes
|
|
8
|
+
|
|
9
|
+
* Fix bug with JSON schema for sequence of discriminated union by @dmontagu in [#7647](https://github.com/pydantic/pydantic/pull/7647)
|
|
10
|
+
* Fix schema references in discriminated unions by @adriangb in [#7646](https://github.com/pydantic/pydantic/pull/7646)
|
|
11
|
+
* Fix json schema generation for recursive models by @adriangb in [#7653](https://github.com/pydantic/pydantic/pull/7653)
|
|
12
|
+
* Fix `models_json_schema` for generic models by @adriangb in [#7654](https://github.com/pydantic/pydantic/pull/7654)
|
|
13
|
+
* Fix xfailed test for generic model signatures by @adriangb in [#7658](https://github.com/pydantic/pydantic/pull/7658)
|
|
14
|
+
|
|
15
|
+
### New Contributors
|
|
16
|
+
|
|
17
|
+
* @austinorr made their first contribution in [#7657](https://github.com/pydantic/pydantic/pull/7657)
|
|
18
|
+
* @peterHoburg made their first contribution in [#7670](https://github.com/pydantic/pydantic/pull/7670)
|
|
19
|
+
|
|
20
|
+
## v2.4.1 (2023-09-26)
|
|
21
|
+
|
|
22
|
+
[GitHub release](https://github.com/pydantic/pydantic/releases/tag/v2.4.1)
|
|
23
|
+
|
|
24
|
+
### What's Changed
|
|
25
|
+
|
|
26
|
+
#### Packaging
|
|
27
|
+
|
|
28
|
+
* Update pydantic-core to 2.10.1 by @davidhewitt in [#7633](https://github.com/pydantic/pydantic/pull/7633)
|
|
29
|
+
|
|
30
|
+
#### Fixes
|
|
31
|
+
|
|
32
|
+
* Serialize unsubstituted type vars as `Any` by @adriangb in [#7606](https://github.com/pydantic/pydantic/pull/7606)
|
|
33
|
+
* Remove schema building caches by @adriangb in [#7624](https://github.com/pydantic/pydantic/pull/7624)
|
|
34
|
+
* Fix an issue where JSON schema extras weren't JSON encoded by @dmontagu in [#7625](https://github.com/pydantic/pydantic/pull/7625)
|
|
35
|
+
|
|
1
36
|
## v2.4.0 (2023-09-22)
|
|
2
37
|
|
|
3
38
|
[GitHub release](https://github.com/pydantic/pydantic/releases/tag/v2.4.0)
|
|
@@ -361,6 +396,11 @@ First pre-release of Pydantic V2!
|
|
|
361
396
|
|
|
362
397
|
See [this post](https://docs.pydantic.dev/blog/pydantic-v2-alpha/) for more details.
|
|
363
398
|
|
|
399
|
+
## v1.10.13 (2023-09-27)
|
|
400
|
+
|
|
401
|
+
* Fix: Add max length check to `pydantic.validate_email`, #7673 by @hramezani
|
|
402
|
+
* Docs: Fix pip commands to install v1, #6930 by @chbndrhnns
|
|
403
|
+
|
|
364
404
|
## v1.10.12 (2023-07-24)
|
|
365
405
|
|
|
366
406
|
* Fixes the `maxlen` property being dropped on `deque` validation. Happened only if the deque item has been typed. Changes the `_validate_sequence_like` func, [#6581](https://github.com/pydantic/pydantic/pull/6581) by @maciekglowka
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pydantic
|
|
3
|
-
Version: 2.4.
|
|
3
|
+
Version: 2.4.2
|
|
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.10.
|
|
38
|
+
Requires-Dist: pydantic-core==2.10.1
|
|
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'
|
|
@@ -113,6 +113,41 @@ See our [security policy](https://github.com/pydantic/pydantic/security/policy).
|
|
|
113
113
|
|
|
114
114
|
## Changelog
|
|
115
115
|
|
|
116
|
+
## v2.4.2 (2023-09-27)
|
|
117
|
+
|
|
118
|
+
[GitHub release](https://github.com/pydantic/pydantic/releases/tag/v2.4.2)
|
|
119
|
+
|
|
120
|
+
### What's Changed
|
|
121
|
+
|
|
122
|
+
#### Fixes
|
|
123
|
+
|
|
124
|
+
* Fix bug with JSON schema for sequence of discriminated union by [@dmontagu](https://github.com/dmontagu) in [#7647](https://github.com/pydantic/pydantic/pull/7647)
|
|
125
|
+
* Fix schema references in discriminated unions by [@adriangb](https://github.com/adriangb) in [#7646](https://github.com/pydantic/pydantic/pull/7646)
|
|
126
|
+
* Fix json schema generation for recursive models by [@adriangb](https://github.com/adriangb) in [#7653](https://github.com/pydantic/pydantic/pull/7653)
|
|
127
|
+
* Fix `models_json_schema` for generic models by [@adriangb](https://github.com/adriangb) in [#7654](https://github.com/pydantic/pydantic/pull/7654)
|
|
128
|
+
* Fix xfailed test for generic model signatures by [@adriangb](https://github.com/adriangb) in [#7658](https://github.com/pydantic/pydantic/pull/7658)
|
|
129
|
+
|
|
130
|
+
### New Contributors
|
|
131
|
+
|
|
132
|
+
* [@austinorr](https://github.com/austinorr) made their first contribution in [#7657](https://github.com/pydantic/pydantic/pull/7657)
|
|
133
|
+
* [@peterHoburg](https://github.com/peterHoburg) made their first contribution in [#7670](https://github.com/pydantic/pydantic/pull/7670)
|
|
134
|
+
|
|
135
|
+
## v2.4.1 (2023-09-26)
|
|
136
|
+
|
|
137
|
+
[GitHub release](https://github.com/pydantic/pydantic/releases/tag/v2.4.1)
|
|
138
|
+
|
|
139
|
+
### What's Changed
|
|
140
|
+
|
|
141
|
+
#### Packaging
|
|
142
|
+
|
|
143
|
+
* Update pydantic-core to 2.10.1 by [@davidhewitt](https://github.com/davidhewitt) in [#7633](https://github.com/pydantic/pydantic/pull/7633)
|
|
144
|
+
|
|
145
|
+
#### Fixes
|
|
146
|
+
|
|
147
|
+
* Serialize unsubstituted type vars as `Any` by [@adriangb](https://github.com/adriangb) in [#7606](https://github.com/pydantic/pydantic/pull/7606)
|
|
148
|
+
* Remove schema building caches by [@adriangb](https://github.com/adriangb) in [#7624](https://github.com/pydantic/pydantic/pull/7624)
|
|
149
|
+
* Fix an issue where JSON schema extras weren't JSON encoded by [@dmontagu](https://github.com/dmontagu) in [#7625](https://github.com/pydantic/pydantic/pull/7625)
|
|
150
|
+
|
|
116
151
|
## v2.4.0 (2023-09-22)
|
|
117
152
|
|
|
118
153
|
[GitHub release](https://github.com/pydantic/pydantic/releases/tag/v2.4.0)
|
|
@@ -476,6 +511,11 @@ First pre-release of Pydantic V2!
|
|
|
476
511
|
|
|
477
512
|
See [this post](https://docs.pydantic.dev/blog/pydantic-v2-alpha/) for more details.
|
|
478
513
|
|
|
514
|
+
## v1.10.13 (2023-09-27)
|
|
515
|
+
|
|
516
|
+
* Fix: Add max length check to `pydantic.validate_email`, [#7673](https://github.com/pydantic/pydantic/issues/7673) by [@hramezani](https://github.com/hramezani)
|
|
517
|
+
* Docs: Fix pip commands to install v1, [#6930](https://github.com/pydantic/pydantic/issues/6930) by [@chbndrhnns](https://github.com/chbndrhnns)
|
|
518
|
+
|
|
479
519
|
## v1.10.12 (2023-07-24)
|
|
480
520
|
|
|
481
521
|
* Fixes the `maxlen` property being dropped on `deque` validation. Happened only if the deque item has been typed. Changes the `_validate_sequence_like` func, [#6581](https://github.com/pydantic/pydantic/pull/6581) by [@maciekglowka](https://github.com/maciekglowka)
|
|
@@ -14,7 +14,7 @@ from typing import (
|
|
|
14
14
|
|
|
15
15
|
from pydantic_core import CoreSchema, core_schema
|
|
16
16
|
from pydantic_core import validate_core_schema as _validate_core_schema
|
|
17
|
-
from typing_extensions import TypeAliasType,
|
|
17
|
+
from typing_extensions import TypeAliasType, TypeGuard, get_args
|
|
18
18
|
|
|
19
19
|
from . import _repr
|
|
20
20
|
|
|
@@ -128,12 +128,6 @@ def collect_definitions(schema: core_schema.CoreSchema) -> dict[str, core_schema
|
|
|
128
128
|
defs: dict[str, CoreSchema] = {}
|
|
129
129
|
|
|
130
130
|
def _record_valid_refs(s: core_schema.CoreSchema, recurse: Recurse) -> core_schema.CoreSchema:
|
|
131
|
-
if 'metadata' in s:
|
|
132
|
-
definitions_cache: _DefinitionsState | None = s['metadata'].get(_DEFINITIONS_CACHE_METADATA_KEY, None)
|
|
133
|
-
if definitions_cache is not None:
|
|
134
|
-
defs.update(definitions_cache['definitions'])
|
|
135
|
-
return s
|
|
136
|
-
|
|
137
131
|
ref = get_ref(s)
|
|
138
132
|
if ref:
|
|
139
133
|
defs[ref] = s
|
|
@@ -175,17 +169,10 @@ def collect_invalid_schemas(schema: core_schema.CoreSchema) -> bool:
|
|
|
175
169
|
metadata = s['metadata']
|
|
176
170
|
if HAS_INVALID_SCHEMAS_METADATA_KEY in metadata:
|
|
177
171
|
invalid = metadata[HAS_INVALID_SCHEMAS_METADATA_KEY]
|
|
178
|
-
if invalid is True:
|
|
179
|
-
invalid = True
|
|
180
172
|
return s
|
|
181
173
|
return recurse(s, _is_schema_valid)
|
|
182
174
|
|
|
183
175
|
walk_core_schema(schema, _is_schema_valid)
|
|
184
|
-
if 'metadata' in schema:
|
|
185
|
-
metadata = schema['metadata']
|
|
186
|
-
metadata[HAS_INVALID_SCHEMAS_METADATA_KEY] = invalid
|
|
187
|
-
else:
|
|
188
|
-
schema['metadata'] = {HAS_INVALID_SCHEMAS_METADATA_KEY: invalid}
|
|
189
176
|
return invalid
|
|
190
177
|
|
|
191
178
|
|
|
@@ -215,7 +202,7 @@ class _WalkCoreSchema:
|
|
|
215
202
|
return f(schema, self._walk)
|
|
216
203
|
|
|
217
204
|
def _walk(self, schema: core_schema.CoreSchema, f: Walk) -> core_schema.CoreSchema:
|
|
218
|
-
schema = self._schema_type_to_method[schema['type']](schema, f)
|
|
205
|
+
schema = self._schema_type_to_method[schema['type']](schema.copy(), f)
|
|
219
206
|
ser_schema: core_schema.SerSchema | None = schema.get('serialization') # type: ignore
|
|
220
207
|
if ser_schema:
|
|
221
208
|
schema['serialization'] = self._handle_ser_schemas(ser_schema, f)
|
|
@@ -436,47 +423,31 @@ def walk_core_schema(schema: core_schema.CoreSchema, f: Walk) -> core_schema.Cor
|
|
|
436
423
|
Returns:
|
|
437
424
|
core_schema.CoreSchema: A processed CoreSchema.
|
|
438
425
|
"""
|
|
439
|
-
return f(schema, _dispatch)
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
class _DefinitionsState(TypedDict):
|
|
443
|
-
definitions: dict[str, core_schema.CoreSchema]
|
|
444
|
-
ref_counts: dict[str, int]
|
|
445
|
-
involved_in_recursion: dict[str, bool]
|
|
446
|
-
current_recursion_ref_count: dict[str, int]
|
|
426
|
+
return f(schema.copy(), _dispatch)
|
|
447
427
|
|
|
448
428
|
|
|
449
429
|
def simplify_schema_references(schema: core_schema.CoreSchema) -> core_schema.CoreSchema: # noqa: C901
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
state = _DefinitionsState(
|
|
455
|
-
definitions={},
|
|
456
|
-
ref_counts=defaultdict(int),
|
|
457
|
-
involved_in_recursion={},
|
|
458
|
-
current_recursion_ref_count=defaultdict(int),
|
|
459
|
-
)
|
|
430
|
+
definitions: dict[str, core_schema.CoreSchema] = {}
|
|
431
|
+
ref_counts: dict[str, int] = defaultdict(int)
|
|
432
|
+
involved_in_recursion: dict[str, bool] = {}
|
|
433
|
+
current_recursion_ref_count: dict[str, int] = defaultdict(int)
|
|
460
434
|
|
|
461
435
|
def collect_refs(s: core_schema.CoreSchema, recurse: Recurse) -> core_schema.CoreSchema:
|
|
462
|
-
if 'metadata' in s:
|
|
463
|
-
definitions_cache: _DefinitionsState | None = s['metadata'].get(_DEFINITIONS_CACHE_METADATA_KEY, None)
|
|
464
|
-
if definitions_cache is not None:
|
|
465
|
-
state['definitions'].update(definitions_cache['definitions'])
|
|
466
|
-
return s
|
|
467
|
-
|
|
468
436
|
if s['type'] == 'definitions':
|
|
469
437
|
for definition in s['definitions']:
|
|
470
438
|
ref = get_ref(definition)
|
|
471
439
|
assert ref is not None
|
|
472
|
-
|
|
440
|
+
if ref not in definitions:
|
|
441
|
+
definitions[ref] = definition
|
|
473
442
|
recurse(definition, collect_refs)
|
|
474
443
|
return recurse(s['schema'], collect_refs)
|
|
475
444
|
else:
|
|
476
445
|
ref = get_ref(s)
|
|
477
446
|
if ref is not None:
|
|
478
|
-
|
|
479
|
-
|
|
447
|
+
new = recurse(s, collect_refs)
|
|
448
|
+
new_ref = get_ref(new)
|
|
449
|
+
if new_ref:
|
|
450
|
+
definitions[new_ref] = new
|
|
480
451
|
return core_schema.definition_reference_schema(schema_ref=ref)
|
|
481
452
|
else:
|
|
482
453
|
return recurse(s, collect_refs)
|
|
@@ -484,53 +455,31 @@ def simplify_schema_references(schema: core_schema.CoreSchema) -> core_schema.Co
|
|
|
484
455
|
schema = walk_core_schema(schema, collect_refs)
|
|
485
456
|
|
|
486
457
|
def count_refs(s: core_schema.CoreSchema, recurse: Recurse) -> core_schema.CoreSchema:
|
|
487
|
-
if 'metadata' in s:
|
|
488
|
-
definitions_cache: _DefinitionsState | None = s['metadata'].get(_DEFINITIONS_CACHE_METADATA_KEY, None)
|
|
489
|
-
if definitions_cache is not None:
|
|
490
|
-
for ref in definitions_cache['ref_counts']:
|
|
491
|
-
state['ref_counts'][ref] += definitions_cache['ref_counts'][ref]
|
|
492
|
-
# it's possible that a schema was seen before we hit the cache
|
|
493
|
-
# and also exists in the cache, in which case it is involved in a recursion
|
|
494
|
-
if state['current_recursion_ref_count'][ref] != 0:
|
|
495
|
-
state['involved_in_recursion'][ref] = True
|
|
496
|
-
# if it's involved in recursion in the inner schema mark it globally as involved in a recursion
|
|
497
|
-
for ref_in_recursion in definitions_cache['involved_in_recursion']:
|
|
498
|
-
if ref_in_recursion:
|
|
499
|
-
state['involved_in_recursion'][ref_in_recursion] = True
|
|
500
|
-
return s
|
|
501
|
-
|
|
502
458
|
if s['type'] != 'definition-ref':
|
|
503
459
|
return recurse(s, count_refs)
|
|
504
460
|
ref = s['schema_ref']
|
|
505
|
-
|
|
461
|
+
ref_counts[ref] += 1
|
|
506
462
|
|
|
507
|
-
if
|
|
463
|
+
if ref_counts[ref] >= 2:
|
|
508
464
|
# If this model is involved in a recursion this should be detected
|
|
509
465
|
# on its second encounter, we can safely stop the walk here.
|
|
510
|
-
if
|
|
511
|
-
|
|
466
|
+
if current_recursion_ref_count[ref] != 0:
|
|
467
|
+
involved_in_recursion[ref] = True
|
|
512
468
|
return s
|
|
513
469
|
|
|
514
|
-
|
|
515
|
-
recurse(
|
|
516
|
-
|
|
470
|
+
current_recursion_ref_count[ref] += 1
|
|
471
|
+
recurse(definitions[ref], count_refs)
|
|
472
|
+
current_recursion_ref_count[ref] -= 1
|
|
517
473
|
return s
|
|
518
474
|
|
|
519
475
|
schema = walk_core_schema(schema, count_refs)
|
|
520
476
|
|
|
521
|
-
assert all(c == 0 for c in
|
|
522
|
-
|
|
523
|
-
definitions_cache = _DefinitionsState(
|
|
524
|
-
definitions=state['definitions'],
|
|
525
|
-
ref_counts=dict(state['ref_counts']),
|
|
526
|
-
involved_in_recursion=state['involved_in_recursion'],
|
|
527
|
-
current_recursion_ref_count=dict(state['current_recursion_ref_count']),
|
|
528
|
-
)
|
|
477
|
+
assert all(c == 0 for c in current_recursion_ref_count.values()), 'this is a bug! please report it'
|
|
529
478
|
|
|
530
479
|
def can_be_inlined(s: core_schema.DefinitionReferenceSchema, ref: str) -> bool:
|
|
531
|
-
if
|
|
480
|
+
if ref_counts[ref] > 1:
|
|
532
481
|
return False
|
|
533
|
-
if
|
|
482
|
+
if involved_in_recursion.get(ref, False):
|
|
534
483
|
return False
|
|
535
484
|
if 'serialization' in s:
|
|
536
485
|
return False
|
|
@@ -553,8 +502,8 @@ def simplify_schema_references(schema: core_schema.CoreSchema) -> core_schema.Co
|
|
|
553
502
|
# any extra keys (like 'serialization')
|
|
554
503
|
if can_be_inlined(s, ref):
|
|
555
504
|
# Inline the reference by replacing the reference with the actual schema
|
|
556
|
-
new =
|
|
557
|
-
|
|
505
|
+
new = definitions.pop(ref)
|
|
506
|
+
ref_counts[ref] -= 1 # because we just replaced it!
|
|
558
507
|
# put all other keys that were on the def-ref schema into the inlined version
|
|
559
508
|
# in particular this is needed for `serialization`
|
|
560
509
|
if 'serialization' in s:
|
|
@@ -568,17 +517,44 @@ def simplify_schema_references(schema: core_schema.CoreSchema) -> core_schema.Co
|
|
|
568
517
|
|
|
569
518
|
schema = walk_core_schema(schema, inline_refs)
|
|
570
519
|
|
|
571
|
-
|
|
520
|
+
def_values = [v for v in definitions.values() if ref_counts[v['ref']] > 0] # type: ignore
|
|
572
521
|
|
|
573
|
-
if
|
|
574
|
-
schema = core_schema.definitions_schema(schema=schema, definitions=
|
|
575
|
-
if 'metadata' in schema:
|
|
576
|
-
schema['metadata'][_DEFINITIONS_CACHE_METADATA_KEY] = definitions_cache
|
|
577
|
-
else:
|
|
578
|
-
schema['metadata'] = {_DEFINITIONS_CACHE_METADATA_KEY: definitions_cache}
|
|
522
|
+
if def_values:
|
|
523
|
+
schema = core_schema.definitions_schema(schema=schema, definitions=def_values)
|
|
579
524
|
return schema
|
|
580
525
|
|
|
581
526
|
|
|
527
|
+
def _strip_metadata(schema: CoreSchema) -> CoreSchema:
|
|
528
|
+
def strip_metadata(s: CoreSchema, recurse: Recurse) -> CoreSchema:
|
|
529
|
+
s = s.copy()
|
|
530
|
+
s.pop('metadata', None)
|
|
531
|
+
if s['type'] == 'model-fields':
|
|
532
|
+
s = s.copy()
|
|
533
|
+
s['fields'] = {k: v.copy() for k, v in s['fields'].items()}
|
|
534
|
+
for field_name, field_schema in s['fields'].items():
|
|
535
|
+
field_schema.pop('metadata', None)
|
|
536
|
+
s['fields'][field_name] = field_schema
|
|
537
|
+
computed_fields = s.get('computed_fields', None)
|
|
538
|
+
if computed_fields:
|
|
539
|
+
s['computed_fields'] = [cf.copy() for cf in computed_fields]
|
|
540
|
+
for cf in computed_fields:
|
|
541
|
+
cf.pop('metadata', None)
|
|
542
|
+
else:
|
|
543
|
+
s.pop('computed_fields', None)
|
|
544
|
+
elif s['type'] == 'model':
|
|
545
|
+
# remove some defaults
|
|
546
|
+
if s.get('custom_init', True) is False:
|
|
547
|
+
s.pop('custom_init')
|
|
548
|
+
if s.get('root_model', True) is False:
|
|
549
|
+
s.pop('root_model')
|
|
550
|
+
if {'title'}.issuperset(s.get('config', {}).keys()):
|
|
551
|
+
s.pop('config', None)
|
|
552
|
+
|
|
553
|
+
return recurse(s, strip_metadata)
|
|
554
|
+
|
|
555
|
+
return walk_core_schema(schema, strip_metadata)
|
|
556
|
+
|
|
557
|
+
|
|
582
558
|
def pretty_print_core_schema(
|
|
583
559
|
schema: CoreSchema,
|
|
584
560
|
include_metadata: bool = False,
|
|
@@ -593,34 +569,7 @@ def pretty_print_core_schema(
|
|
|
593
569
|
from rich import print # type: ignore # install it manually in your dev env
|
|
594
570
|
|
|
595
571
|
if not include_metadata:
|
|
596
|
-
|
|
597
|
-
def strip_metadata(s: CoreSchema, recurse: Recurse) -> CoreSchema:
|
|
598
|
-
s.pop('metadata', None)
|
|
599
|
-
if s['type'] == 'model-fields':
|
|
600
|
-
s = s.copy()
|
|
601
|
-
s['fields'] = {k: v.copy() for k, v in s['fields'].items()}
|
|
602
|
-
for field_name, field_schema in s['fields'].items():
|
|
603
|
-
field_schema.pop('metadata', None)
|
|
604
|
-
s['fields'][field_name] = field_schema
|
|
605
|
-
computed_fields = s.get('computed_fields', None)
|
|
606
|
-
if computed_fields:
|
|
607
|
-
s['computed_fields'] = [cf.copy() for cf in computed_fields]
|
|
608
|
-
for cf in computed_fields:
|
|
609
|
-
cf.pop('metadata', None)
|
|
610
|
-
else:
|
|
611
|
-
s.pop('computed_fields', None)
|
|
612
|
-
elif s['type'] == 'model':
|
|
613
|
-
# remove some defaults
|
|
614
|
-
if s.get('custom_init', True) is False:
|
|
615
|
-
s.pop('custom_init')
|
|
616
|
-
if s.get('root_model', True) is False:
|
|
617
|
-
s.pop('root_model')
|
|
618
|
-
if {'title'}.issuperset(s.get('config', {}).keys()):
|
|
619
|
-
s.pop('config')
|
|
620
|
-
|
|
621
|
-
return recurse(s, strip_metadata)
|
|
622
|
-
|
|
623
|
-
schema = walk_core_schema(schema, strip_metadata)
|
|
572
|
+
schema = _strip_metadata(schema)
|
|
624
573
|
|
|
625
574
|
return print(schema)
|
|
626
575
|
|
|
@@ -6,7 +6,12 @@ from pydantic_core import CoreSchema, core_schema
|
|
|
6
6
|
|
|
7
7
|
from ..errors import PydanticUserError
|
|
8
8
|
from . import _core_utils
|
|
9
|
-
from ._core_utils import
|
|
9
|
+
from ._core_utils import (
|
|
10
|
+
NEEDS_APPLY_DISCRIMINATED_UNION_METADATA_KEY,
|
|
11
|
+
CoreSchemaField,
|
|
12
|
+
collect_definitions,
|
|
13
|
+
simplify_schema_references,
|
|
14
|
+
)
|
|
10
15
|
|
|
11
16
|
CORE_SCHEMA_METADATA_DISCRIMINATOR_PLACEHOLDER_KEY = 'pydantic.internal.union_discriminator'
|
|
12
17
|
|
|
@@ -49,7 +54,7 @@ def apply_discriminators(schema: core_schema.CoreSchema) -> core_schema.CoreSche
|
|
|
49
54
|
s = apply_discriminator(s, discriminator, definitions)
|
|
50
55
|
return s
|
|
51
56
|
|
|
52
|
-
return _core_utils.walk_core_schema(schema, inner)
|
|
57
|
+
return simplify_schema_references(_core_utils.walk_core_schema(schema, inner))
|
|
53
58
|
|
|
54
59
|
|
|
55
60
|
def apply_discriminator(
|
|
@@ -177,6 +182,10 @@ class _ApplyInferredDiscriminator:
|
|
|
177
182
|
if self._should_be_nullable and not self._is_nullable:
|
|
178
183
|
schema = core_schema.nullable_schema(schema)
|
|
179
184
|
self._used = True
|
|
185
|
+
new_defs = collect_definitions(schema)
|
|
186
|
+
missing_defs = self.definitions.keys() - new_defs.keys()
|
|
187
|
+
if missing_defs:
|
|
188
|
+
schema = core_schema.definitions_schema(schema, [self.definitions[ref] for ref in missing_defs])
|
|
180
189
|
return schema
|
|
181
190
|
|
|
182
191
|
def _apply_to_root(self, schema: core_schema.CoreSchema) -> core_schema.CoreSchema:
|
|
@@ -33,7 +33,7 @@ from typing import (
|
|
|
33
33
|
)
|
|
34
34
|
from warnings import warn
|
|
35
35
|
|
|
36
|
-
from pydantic_core import CoreSchema, PydanticUndefined, core_schema
|
|
36
|
+
from pydantic_core import CoreSchema, PydanticUndefined, core_schema, to_jsonable_python
|
|
37
37
|
from typing_extensions import Annotated, Final, Literal, TypeAliasType, TypedDict, get_args, get_origin, is_typeddict
|
|
38
38
|
|
|
39
39
|
from ..annotated_handlers import GetCoreSchemaHandler, GetJsonSchemaHandler
|
|
@@ -50,10 +50,10 @@ from ._core_metadata import (
|
|
|
50
50
|
build_metadata_dict,
|
|
51
51
|
)
|
|
52
52
|
from ._core_utils import (
|
|
53
|
-
HAS_INVALID_SCHEMAS_METADATA_KEY,
|
|
54
53
|
NEEDS_APPLY_DISCRIMINATED_UNION_METADATA_KEY,
|
|
55
54
|
CoreSchemaOrField,
|
|
56
55
|
define_expected_missing_refs,
|
|
56
|
+
get_ref,
|
|
57
57
|
get_type_ref,
|
|
58
58
|
is_list_like_schema_with_items_schema,
|
|
59
59
|
)
|
|
@@ -396,6 +396,8 @@ class GenerateSchema:
|
|
|
396
396
|
ref = cast('str | None', schema.get('ref', None))
|
|
397
397
|
if ref:
|
|
398
398
|
self.defs.definitions[ref] = schema
|
|
399
|
+
if 'ref' in schema:
|
|
400
|
+
schema = core_schema.definition_reference_schema(schema['ref'])
|
|
399
401
|
return core_schema.definitions_schema(
|
|
400
402
|
schema,
|
|
401
403
|
list(self.defs.definitions.values()),
|
|
@@ -532,10 +534,6 @@ class GenerateSchema:
|
|
|
532
534
|
new_inner_schema = define_expected_missing_refs(inner_schema, recursively_defined_type_refs())
|
|
533
535
|
if new_inner_schema is not None:
|
|
534
536
|
inner_schema = new_inner_schema
|
|
535
|
-
self._has_invalid_schema = True
|
|
536
|
-
metadata[HAS_INVALID_SCHEMAS_METADATA_KEY] = True
|
|
537
|
-
else:
|
|
538
|
-
metadata[HAS_INVALID_SCHEMAS_METADATA_KEY] = False
|
|
539
537
|
inner_schema = apply_model_validators(inner_schema, model_validators, 'inner')
|
|
540
538
|
|
|
541
539
|
model_schema = core_schema.model_schema(
|
|
@@ -605,7 +603,7 @@ class GenerateSchema:
|
|
|
605
603
|
|
|
606
604
|
schema = self._unpack_refs_defs(schema)
|
|
607
605
|
|
|
608
|
-
ref
|
|
606
|
+
ref = get_ref(schema)
|
|
609
607
|
if ref:
|
|
610
608
|
self.defs.definitions[ref] = self._post_process_generated_schema(schema)
|
|
611
609
|
return core_schema.definition_reference_schema(ref)
|
|
@@ -671,11 +669,9 @@ class GenerateSchema:
|
|
|
671
669
|
if 'metadata' in schema:
|
|
672
670
|
metadata = schema['metadata']
|
|
673
671
|
metadata[NEEDS_APPLY_DISCRIMINATED_UNION_METADATA_KEY] = self._needs_apply_discriminated_union
|
|
674
|
-
metadata[HAS_INVALID_SCHEMAS_METADATA_KEY] = self._has_invalid_schema
|
|
675
672
|
else:
|
|
676
673
|
schema['metadata'] = {
|
|
677
674
|
NEEDS_APPLY_DISCRIMINATED_UNION_METADATA_KEY: self._needs_apply_discriminated_union,
|
|
678
|
-
HAS_INVALID_SCHEMAS_METADATA_KEY: self._has_invalid_schema,
|
|
679
675
|
}
|
|
680
676
|
return schema
|
|
681
677
|
|
|
@@ -957,7 +953,7 @@ class GenerateSchema:
|
|
|
957
953
|
json_schema_updates = {
|
|
958
954
|
'title': field_info.title,
|
|
959
955
|
'description': field_info.description,
|
|
960
|
-
'examples': field_info.examples,
|
|
956
|
+
'examples': to_jsonable_python(field_info.examples),
|
|
961
957
|
}
|
|
962
958
|
json_schema_updates = {k: v for k, v in json_schema_updates.items() if v is not None}
|
|
963
959
|
|
|
@@ -966,7 +962,7 @@ class GenerateSchema:
|
|
|
966
962
|
def json_schema_update_func(schema: CoreSchemaOrField, handler: GetJsonSchemaHandler) -> JsonSchemaValue:
|
|
967
963
|
json_schema = {**handler(schema), **json_schema_updates}
|
|
968
964
|
if isinstance(json_schema_extra, dict):
|
|
969
|
-
json_schema.update(json_schema_extra)
|
|
965
|
+
json_schema.update(to_jsonable_python(json_schema_extra))
|
|
970
966
|
elif callable(json_schema_extra):
|
|
971
967
|
json_schema_extra(json_schema)
|
|
972
968
|
return json_schema
|
|
@@ -1264,12 +1260,6 @@ class GenerateSchema:
|
|
|
1264
1260
|
"""Generate schema for a Sequence, e.g. `Sequence[int]`."""
|
|
1265
1261
|
item_type = self._get_first_arg_or_any(sequence_type)
|
|
1266
1262
|
|
|
1267
|
-
def json_schema_func(_schema: CoreSchemaOrField, handler: GetJsonSchemaHandler) -> JsonSchemaValue:
|
|
1268
|
-
items_schema = self._generate_schema(item_type)
|
|
1269
|
-
return handler(core_schema.list_schema(items_schema))
|
|
1270
|
-
|
|
1271
|
-
metadata = build_metadata_dict(js_functions=[json_schema_func])
|
|
1272
|
-
|
|
1273
1263
|
list_schema = core_schema.list_schema(self.generate_schema(item_type))
|
|
1274
1264
|
python_schema = core_schema.is_instance_schema(typing.Sequence, cls_repr='Sequence')
|
|
1275
1265
|
if item_type != Any:
|
|
@@ -1278,9 +1268,7 @@ class GenerateSchema:
|
|
|
1278
1268
|
python_schema = core_schema.chain_schema(
|
|
1279
1269
|
[python_schema, core_schema.no_info_wrap_validator_function(sequence_validator, list_schema)],
|
|
1280
1270
|
)
|
|
1281
|
-
return core_schema.json_or_python_schema(
|
|
1282
|
-
json_schema=list_schema, python_schema=python_schema, metadata=metadata
|
|
1283
|
-
)
|
|
1271
|
+
return core_schema.json_or_python_schema(json_schema=list_schema, python_schema=python_schema)
|
|
1284
1272
|
|
|
1285
1273
|
def _iterable_schema(self, type_: Any) -> core_schema.GeneratorSchema:
|
|
1286
1274
|
"""Generate a schema for an `Iterable`."""
|
|
@@ -1449,10 +1437,26 @@ class GenerateSchema:
|
|
|
1449
1437
|
def _unsubstituted_typevar_schema(self, typevar: typing.TypeVar) -> core_schema.CoreSchema:
|
|
1450
1438
|
assert isinstance(typevar, typing.TypeVar)
|
|
1451
1439
|
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1440
|
+
bound = typevar.__bound__
|
|
1441
|
+
constraints = typevar.__constraints__
|
|
1442
|
+
not_set = object()
|
|
1443
|
+
default = getattr(typevar, '__default__', not_set)
|
|
1444
|
+
|
|
1445
|
+
if (bound is not None) + (len(constraints) != 0) + (default is not not_set) > 1:
|
|
1446
|
+
raise NotImplementedError(
|
|
1447
|
+
'Pydantic does not support mixing more than one of TypeVar bounds, constraints and defaults'
|
|
1448
|
+
)
|
|
1449
|
+
|
|
1450
|
+
if default is not not_set:
|
|
1451
|
+
return self.generate_schema(default)
|
|
1452
|
+
elif constraints:
|
|
1453
|
+
return self._union_schema(typing.Union[constraints]) # type: ignore
|
|
1454
|
+
elif bound:
|
|
1455
|
+
schema = self.generate_schema(bound)
|
|
1456
|
+
schema['serialization'] = core_schema.wrap_serializer_function_ser_schema(
|
|
1457
|
+
lambda x, h: h(x), schema=core_schema.any_schema()
|
|
1458
|
+
)
|
|
1459
|
+
return schema
|
|
1456
1460
|
else:
|
|
1457
1461
|
return core_schema.any_schema()
|
|
1458
1462
|
|
|
@@ -1643,7 +1647,7 @@ class GenerateSchema:
|
|
|
1643
1647
|
if metadata.description:
|
|
1644
1648
|
json_schema_update['description'] = metadata.description
|
|
1645
1649
|
if metadata.examples:
|
|
1646
|
-
json_schema_update['examples'] = metadata.examples
|
|
1650
|
+
json_schema_update['examples'] = to_jsonable_python(metadata.examples)
|
|
1647
1651
|
|
|
1648
1652
|
json_schema_extra = metadata.json_schema_extra
|
|
1649
1653
|
if json_schema_update or json_schema_extra:
|
|
@@ -1654,7 +1658,7 @@ class GenerateSchema:
|
|
|
1654
1658
|
json_schema = handler(core_schema)
|
|
1655
1659
|
json_schema.update(json_schema_update)
|
|
1656
1660
|
if isinstance(json_schema_extra, dict):
|
|
1657
|
-
json_schema.update(json_schema_extra)
|
|
1661
|
+
json_schema.update(to_jsonable_python(json_schema_extra))
|
|
1658
1662
|
elif callable(json_schema_extra):
|
|
1659
1663
|
json_schema_extra(json_schema)
|
|
1660
1664
|
return json_schema
|
|
@@ -101,7 +101,10 @@ def display_as_type(obj: Any) -> str:
|
|
|
101
101
|
args = ', '.join(map(display_as_type, typing_extensions.get_args(obj)))
|
|
102
102
|
return f'Union[{args}]'
|
|
103
103
|
elif isinstance(obj, _typing_extra.WithArgsTypes):
|
|
104
|
-
|
|
104
|
+
if typing_extensions.get_origin(obj) == typing_extensions.Literal:
|
|
105
|
+
args = ', '.join(map(repr, typing_extensions.get_args(obj)))
|
|
106
|
+
else:
|
|
107
|
+
args = ', '.join(map(display_as_type, typing_extensions.get_args(obj)))
|
|
105
108
|
return f'{obj.__qualname__}[{args}]'
|
|
106
109
|
elif isinstance(obj, type):
|
|
107
110
|
return obj.__qualname__
|
|
@@ -2180,6 +2180,10 @@ def models_json_schema(
|
|
|
2180
2180
|
- The second element is a JSON schema containing all definitions referenced in the first returned
|
|
2181
2181
|
element, along with the optional title and description keys.
|
|
2182
2182
|
"""
|
|
2183
|
+
for cls, _ in models:
|
|
2184
|
+
if isinstance(cls.__pydantic_validator__, _mock_val_ser.MockValSer):
|
|
2185
|
+
cls.__pydantic_validator__.rebuild()
|
|
2186
|
+
|
|
2183
2187
|
instance = schema_generator(by_alias=by_alias, ref_template=ref_template)
|
|
2184
2188
|
inputs = [(m, mode, m.__pydantic_core_schema__) for m, mode in models]
|
|
2185
2189
|
json_schemas_map, definitions = instance.generate_definitions(inputs)
|
|
@@ -147,7 +147,7 @@ def parse_time(value: Union[time, StrBytesIntFloat]) -> time:
|
|
|
147
147
|
number = get_numeric(value, 'time')
|
|
148
148
|
if number is not None:
|
|
149
149
|
if number >= 86400:
|
|
150
|
-
# doesn't make sense since the time loop back around to 0
|
|
150
|
+
# doesn't make sense since the time time loop back around to 0
|
|
151
151
|
raise errors.TimeError()
|
|
152
152
|
return (datetime.min + timedelta(seconds=number)).time()
|
|
153
153
|
|
|
@@ -263,7 +263,7 @@ def Field(
|
|
|
263
263
|
Takes same values as the ``include`` and ``exclude`` arguments on the ``.dict`` method.
|
|
264
264
|
:param include: include this field while dumping.
|
|
265
265
|
Takes same values as the ``include`` and ``exclude`` arguments on the ``.dict`` method.
|
|
266
|
-
:param const: this field is required and *must* take
|
|
266
|
+
:param const: this field is required and *must* take it's default value
|
|
267
267
|
:param gt: only applies to numbers, requires the field to be "greater than". The schema
|
|
268
268
|
will have an ``exclusiveMinimum`` validation keyword
|
|
269
269
|
:param ge: only applies to numbers, requires the field to be "greater than or equal to". The
|
|
@@ -161,9 +161,9 @@ class ModelMetaclass(ABCMeta):
|
|
|
161
161
|
|
|
162
162
|
for f in fields.values():
|
|
163
163
|
f.set_config(config)
|
|
164
|
-
|
|
165
|
-
if
|
|
166
|
-
f.class_validators.update(
|
|
164
|
+
extra_validators = vg.get_validators(f.name)
|
|
165
|
+
if extra_validators:
|
|
166
|
+
f.class_validators.update(extra_validators)
|
|
167
167
|
# re-run prepare to add extra validators
|
|
168
168
|
f.populate_validators()
|
|
169
169
|
|
|
@@ -702,6 +702,10 @@ class IPvAnyNetwork(_BaseNetwork): # type: ignore
|
|
|
702
702
|
|
|
703
703
|
|
|
704
704
|
pretty_email_regex = re.compile(r'([\w ]*?) *<(.*)> *')
|
|
705
|
+
MAX_EMAIL_LENGTH = 2048
|
|
706
|
+
"""Maximum length for an email.
|
|
707
|
+
A somewhat arbitrary but very generous number compared to what is allowed by most implementations.
|
|
708
|
+
"""
|
|
705
709
|
|
|
706
710
|
|
|
707
711
|
def validate_email(value: Union[str]) -> Tuple[str, str]:
|
|
@@ -714,6 +718,10 @@ def validate_email(value: Union[str]) -> Tuple[str, str]:
|
|
|
714
718
|
"""
|
|
715
719
|
if email_validator is None:
|
|
716
720
|
import_email_validator()
|
|
721
|
+
|
|
722
|
+
if len(value) > MAX_EMAIL_LENGTH:
|
|
723
|
+
raise errors.EmailError()
|
|
724
|
+
|
|
717
725
|
m = pretty_email_regex.fullmatch(value)
|
|
718
726
|
name: Union[str, None] = None
|
|
719
727
|
if m:
|