pydantic / pydantic

Data validation using Python type hints
https://docs.pydantic.dev
MIT License
21.14k stars 1.9k forks source link

2.9.2: pytest fails in 4 units #10488

Closed kloczek closed 1 month ago

kloczek commented 1 month ago

Initial Checks

Description

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

List of installed modules in build env: ```console Package Version ------------------------- ----------- annotated-types 0.7.0 attrs 24.2.0 black 24.4.2 build 1.2.2 click 8.1.7 cloudpickle 3.0.0 dirty-equals 0.7.1.post0 distro 1.9.0 dnspython 2.6.1 email_validator 2.2.0 exceptiongroup 1.1.3 Faker 29.0.0 hatch-fancy-pypi-readme 24.1.0 hatchling 1.25.0 hypothesis 6.100.0 importlib_metadata 8.0.0 iniconfig 2.0.0 installer 0.7.0 jsonschema 4.20.0 jsonschema-specifications 2023.12.1 markdown-it-py 3.0.0 mdurl 0.1.2 mypy 1.11.2 mypy_extensions 1.0.0 packaging 24.0 pathspec 0.12.1 platformdirs 4.3.6 pluggy 1.5.0 py-cpuinfo 9.0.0 pydantic_core 2.24.0 Pygments 2.18.0 pyproject_hooks 1.0.0 pytest 8.2.2 pytest-benchmark 4.0.0 pytest-examples 0.0.13 pytest-mock 3.14.0 python-dateutil 2.9.0.post0 pytz 2024.2 referencing 0.32.0 rich 13.7.1 rpds-py 0.20.0 sortedcontainers 2.4.0 tokenize_rt 6.0.0 tomli 2.0.1 trove-classifiers 2024.9.16 typing_extensions 4.12.2 wheel 0.44.0 zipp 3.19.2 ```

Please let me know if you need more details or want me to perform some diagnostics.

Example Code

N/A

Python, Pydantic & OS Version

2.9.2
kloczek commented 1 month ago

Looks like pytest fails in 4 units. One unit fails because it tries to reach mongodb port on localhost (IMO it should be possible to disable that unit by pytest mark like -m "not mongo").

Here is pytest output: ```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pydantic-2.9.2-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pydantic-2.9.2-2.fc37.x86_64/usr/lib/python3.10/site-packages + /usr/bin/pytest -ra -m 'not network' ==================================================================================== test session starts ==================================================================================== platform linux -- Python 3.10.14, pytest-8.2.2, pluggy-1.5.0 benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=True warmup_iterations=100000) rootdir: /home/tkloczko/rpmbuild/BUILD/pydantic-2.9.2 configfile: pyproject.toml testpaths: tests plugins: hypothesis-6.100.0, benchmark-4.0.0, timeout-2.3.1, mock-3.14.0, examples-0.0.13, Faker-29.0.0 collected 5890 items tests/benchmarks/test_discriminated_unions.py .. [ 0%] tests/benchmarks/test_fastapi_startup_generics.py . [ 0%] tests/benchmarks/test_fastapi_startup_simple.py . [ 0%] tests/benchmarks/test_imports.py .. [ 0%] tests/benchmarks/test_isinstance.py . [ 0%] tests/benchmarks/test_model_schema_generation.py ...................... [ 0%] tests/benchmarks/test_model_serialization.py ..... [ 0%] tests/benchmarks/test_model_validation.py ........ [ 0%] tests/benchmarks/test_north_star.py ........ [ 0%] tests/mypy/test_mypy.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss [ 1%] tests/plugin/test_plugin.py s [ 1%] tests/test_abc.py .s [ 1%] tests/test_aliases.py ........................................................... [ 2%] tests/test_annotated.py .................................... [ 3%] tests/test_assert_in_validators.py . [ 3%] tests/test_callable.py ........ [ 3%] tests/test_color.py .......................................................................................... [ 5%] tests/test_computed_fields.py ....................sss....x...s [ 5%] tests/test_config.py .......................................s............................................ [ 7%] tests/test_construction.py ................................................... [ 8%] tests/test_create_model.py ............................................... [ 8%] tests/test_dataclasses.py ...................................................................................................................s....................................... [ 11%] .............................................................. [ 12%] tests/test_datetime.py .............................................................................................................................................................. [ 15%] .................................. [ 15%] tests/test_decorators.py ............................ [ 16%] tests/test_deprecated.py ................................................ [ 17%] tests/test_deprecated_fields.py ........ [ 17%] tests/test_deprecated_validate_arguments.py ..................... [ 17%] tests/test_discriminated_union.py ..........................................................x.........x [ 18%] tests/test_docs.py ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss [ 21%] sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss [ 24%] sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss [ 27%] ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.. [ 28%] tests/test_docs_extraction.py ............. [ 28%] tests/test_edge_cases.py ...................................................................................................................s...................................sss.. [ 31%] .................. [ 31%] tests/test_errors.py ... [ 31%] tests/test_exports.py ................................................................................................................................................... [ 34%] tests/test_fastapi_json_schema.py .. [ 34%] tests/test_fields.py ................... [ 34%] tests/test_forward_ref.py ............................................. [ 35%] tests/test_generics.py ..................................s.........s............................................sx.......sss............ [ 37%] tests/test_internal.py .........s. [ 37%] tests/test_json.py ...............................F........................... [ 38%] tests/test_json_schema.py ..............................................................................................................................F...F...F.................... [ 41%] ..............................................................................................................................................................x...................... [ 44%] .................................................................s.............. [ 45%] tests/test_main.py .........................................................................................................sssssssssssssssssssssssss................................ [ 48%] ...................x.............................................................. [ 49%] tests/test_meta.py x [ 49%] tests/test_migration.py ............................................................................................................................................................. [ 52%] ....................................................................... [ 53%] tests/test_model_signature.py .............s. [ 54%] tests/test_model_validator.py ........ [ 54%] tests/test_networks.py .............................................................................................................................................................. [ 56%] .......................................x.............................................................................s.. [ 58%] tests/test_networks_ipaddress.py .................................................................................................................................................... [ 61%] ............... [ 61%] tests/test_parse.py ........... [ 61%] tests/test_pickle.py ..................... [ 62%] tests/test_pipeline.py .............................................................. [ 63%] tests/test_plugin_loader.py ...... [ 63%] tests/test_plugins.py ............. [ 63%] tests/test_private_attributes.py ........................ [ 64%] tests/test_rich_repr.py .. [ 64%] tests/test_root_model.py ............................................................................ [ 65%] tests/test_serialize.py .................................................................................. [ 66%] tests/test_serialize_as_any.py .............. [ 66%] tests/test_strict.py ...... [ 67%] tests/test_structural_pattern_matching.py . [ 67%] tests/test_titles.py .........................sss...ssss....ssss....ssss....ss..ss..s.s..ssssss......ssssss......ssssss......ssssss...... [ 69%] tests/test_tools.py ......... [ 69%] tests/test_type_adapter.py .........................................................x................................................................................................ [ 71%] ............................................................................................................................................... [ 74%] tests/test_type_alias_type.py ........x.... [ 74%] tests/test_type_hints.py ...... [ 74%] tests/test_types.py ..................................................s..........................x................................................................................... [ 77%] .......................................................................................................................................ss............................................ [ 80%] ..................................................................................................................................................................................... [ 83%] ..................................................................................................................................................................................... [ 86%] ..................................................................................................................................................................................... [ 89%] ......................... [ 90%] tests/test_types_namedtuple.py ........... [ 90%] tests/test_types_payment_card_number.py .............................................. [ 90%] tests/test_types_self.py s.s.s.s.s.s.s.s.s.s. [ 91%] tests/test_types_typeddict.py ..sss.sss.s.s.s.s.s.s.sss..sss.sss.s.sss..........s.s.s.s.s.s....... [ 92%] tests/test_types_zoneinfo.py ...... [ 92%] tests/test_typing.py ................s... [ 92%] tests/test_utils.py ..............................................................................s.................................................................................. [ 95%] ..................... [ 96%] tests/test_v1.py .. [ 96%] tests/test_validate_call.py ........................................s. [ 96%] tests/test_validators.py ............................................................................................................................................................ [ 99%] ...........x.... [ 99%] tests/test_validators_dataclass.py ........ [ 99%] tests/test_version.py ...... [ 99%] tests/test_warnings.py ..... [100%] ========================================================================================= FAILURES ========================================================================================== _______________________________________________________________________________ test_subclass_custom_encoding _______________________________________________________________________________ def test_subclass_custom_encoding(): class SubDt(datetime): @classmethod def __get_pydantic_core_schema__(cls, source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema: def val(v: datetime) -> SubDt: return SubDt.fromtimestamp(v.timestamp()) return core_schema.no_info_after_validator_function(val, handler(datetime)) class SubDelta(timedelta): @classmethod def __get_pydantic_core_schema__(cls, source_type: Any, handler: GetCoreSchemaHandler) -> CoreSchema: def val(v: timedelta) -> SubDelta: return cls(seconds=v.total_seconds()) return core_schema.no_info_after_validator_function(val, handler(timedelta)) > class Model(BaseModel): tests/test_json.py:174: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pydantic/_internal/_model_construction.py:224: in __new__ complete_model_class( pydantic/_internal/_model_construction.py:587: in complete_model_class schema = gen_schema.clean_schema(schema) pydantic/_internal/_generate_schema.py:595: in clean_schema schema = validate_core_schema(schema) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ schema = {'cls': .Model'>, 'config': {'ser_json_timedelta': 'floa...seModel.__get_pydantic_json_schema__ of .Model'>>]}, ...} def validate_core_schema(schema: CoreSchema) -> CoreSchema: if 'PYDANTIC_SKIP_VALIDATING_CORE_SCHEMAS' in os.environ: return schema > return _validate_core_schema(schema) E pydantic_core._pydantic_core.SchemaError: Invalid Schema: E model.config.ser_json_timedelta E Input should be 'iso8601', 'seconds_float' or 'milliseconds_float' [type=literal_error, input_value='float', input_type=str] pydantic/_internal/_core_utils.py:570: SchemaError ______________________________________________________________________ test_model_default_timedelta[float-properties0] ______________________________________________________________________ ser_json_timedelta = 'float', properties = {'duration': {'default': 300.0, 'title': 'Duration', 'type': 'number'}} @pytest.mark.parametrize( 'ser_json_timedelta,properties', [ ('float', {'duration': {'default': 300.0, 'title': 'Duration', 'type': 'number'}}), ('iso8601', {'duration': {'default': 'PT5M', 'format': 'duration', 'title': 'Duration', 'type': 'string'}}), ], ) def test_model_default_timedelta(ser_json_timedelta: Literal['float', 'iso8601'], properties: typing.Dict[str, Any]): > class Model(BaseModel): tests/test_json_schema.py:1785: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pydantic/_internal/_model_construction.py:224: in __new__ complete_model_class( pydantic/_internal/_model_construction.py:587: in complete_model_class schema = gen_schema.clean_schema(schema) pydantic/_internal/_generate_schema.py:595: in clean_schema schema = validate_core_schema(schema) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ schema = {'cls': .Model'>, 'config': {'ser_json_timedelta':...l.__get_pydantic_json_schema__ of .Model'>>]}, ...} def validate_core_schema(schema: CoreSchema) -> CoreSchema: if 'PYDANTIC_SKIP_VALIDATING_CORE_SCHEMAS' in os.environ: return schema > return _validate_core_schema(schema) E pydantic_core._pydantic_core.SchemaError: Invalid Schema: E model.config.ser_json_timedelta E Input should be 'iso8601', 'seconds_float' or 'milliseconds_float' [type=literal_error, input_value='float', input_type=str] pydantic/_internal/_core_utils.py:570: SchemaError ____________________________________________________________________ test_dataclass_default_timedelta[float-properties0] ____________________________________________________________________ ser_json_timedelta = 'float', properties = {'duration': {'default': 300.0, 'title': 'Duration', 'type': 'number'}} @pytest.mark.parametrize( 'ser_json_timedelta,properties', [ ('float', {'duration': {'default': 300.0, 'title': 'Duration', 'type': 'number'}}), ('iso8601', {'duration': {'default': 'PT5M', 'format': 'duration', 'title': 'Duration', 'type': 'string'}}), ], ) def test_dataclass_default_timedelta( ser_json_timedelta: Literal['float', 'iso8601'], properties: typing.Dict[str, Any] ): @dataclass(config=ConfigDict(ser_json_timedelta=ser_json_timedelta)) > class Dataclass: tests/test_json_schema.py:1830: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pydantic/dataclasses.py:261: in create_dataclass _pydantic_dataclasses.complete_dataclass(cls, config_wrapper, raise_errors=False, types_namespace=None) pydantic/_internal/_dataclasses.py:170: in complete_dataclass schema = gen_schema.clean_schema(schema) pydantic/_internal/_generate_schema.py:595: in clean_schema schema = validate_core_schema(schema) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ schema = {'cls': .Dataclass'>, 'config': {'ser_json_timedelta': 'float', 'title': 'Dataclass'}, 'fields': ['duration'], 'frozen': False, ...} def validate_core_schema(schema: CoreSchema) -> CoreSchema: if 'PYDANTIC_SKIP_VALIDATING_CORE_SCHEMAS' in os.environ: return schema > return _validate_core_schema(schema) E pydantic_core._pydantic_core.SchemaError: Invalid Schema: E dataclass.config.ser_json_timedelta E Input should be 'iso8601', 'seconds_float' or 'milliseconds_float' [type=literal_error, input_value='float', input_type=str] pydantic/_internal/_core_utils.py:570: SchemaError ____________________________________________________________________ test_typeddict_default_timedelta[float-properties0] ____________________________________________________________________ ser_json_timedelta = 'float', properties = {'duration': {'default': 300.0, 'title': 'Duration', 'type': 'number'}} @pytest.mark.parametrize( 'ser_json_timedelta,properties', [ ('float', {'duration': {'default': 300.0, 'title': 'Duration', 'type': 'number'}}), ('iso8601', {'duration': {'default': 'PT5M', 'format': 'duration', 'title': 'Duration', 'type': 'string'}}), ], ) def test_typeddict_default_timedelta( ser_json_timedelta: Literal['float', 'iso8601'], properties: typing.Dict[str, Any] ): class MyTypedDict(TypedDict): __pydantic_config__ = ConfigDict(ser_json_timedelta=ser_json_timedelta) duration: Annotated[timedelta, Field(timedelta(minutes=5))] # insert_assert(TypeAdapter(MyTypedDict).json_schema(mode='serialization')) > assert TypeAdapter(MyTypedDict).json_schema(mode='serialization') == { 'properties': properties, 'title': 'MyTypedDict', 'type': 'object', } tests/test_json_schema.py:1877: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pydantic/type_adapter.py:257: in __init__ self._init_core_attrs(rebuild_mocks=False) pydantic/type_adapter.py:135: in wrapped return func(self, *args, **kwargs) pydantic/type_adapter.py:277: in _init_core_attrs self._core_schema = _get_schema(self._type, config_wrapper, parent_depth=self._parent_depth) pydantic/type_adapter.py:96: in _get_schema schema = gen.clean_schema(schema) pydantic/_internal/_generate_schema.py:595: in clean_schema schema = validate_core_schema(schema) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ schema = {'cls': .MyTypedDict'>, 'computed_fields': [],...a': {'microseconds_precision': 'truncate', 'type': 'timedelta'}, 'type': 'default'}, 'type': 'typed-dict-field'}}, ...} def validate_core_schema(schema: CoreSchema) -> CoreSchema: if 'PYDANTIC_SKIP_VALIDATING_CORE_SCHEMAS' in os.environ: return schema > return _validate_core_schema(schema) E pydantic_core._pydantic_core.SchemaError: Invalid Schema: E typed-dict.config.ser_json_timedelta E Input should be 'iso8601', 'seconds_float' or 'milliseconds_float' [type=literal_error, input_value='float', input_type=str] pydantic/_internal/_core_utils.py:570: SchemaError ========================================================================================= XFAILURES ========================================================================================= ____________________________________________________________________ test_multiple_references_to_schema[make_typed_dict] ____________________________________________________________________ model_factory = @pytest.mark.parametrize( 'model_factory', [ make_base_model, pytest.param( make_typed_dict, marks=pytest.mark.xfail( reason='computed fields do not work with TypedDict yet. See https://github.com/pydantic/pydantic-core/issues/657' ), ), make_dataclass, ], ) def test_multiple_references_to_schema(model_factory: Callable[[], Any]) -> None: """ https://github.com/pydantic/pydantic/issues/5980 """ model = model_factory() ta = TypeAdapter(model) > assert ta.dump_python(model()) == {'comp_1': {}, 'comp_2': {}} tests/test_computed_fields.py:727: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pydantic/type_adapter.py:135: in wrapped return func(self, *args, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , instance = {} @_frame_depth(1) def dump_python( self, instance: T, /, *, mode: Literal['json', 'python'] = 'python', include: IncEx | None = None, exclude: IncEx | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False, context: dict[str, Any] | None = None, ) -> Any: """Dump an instance of the adapted type to a Python object. Args: instance: The Python object to serialize. mode: The output format. include: Fields to include in the output. exclude: Fields to exclude from the output. by_alias: Whether to use alias names for field names. exclude_unset: Whether to exclude unset fields. exclude_defaults: Whether to exclude fields with default values. exclude_none: Whether to exclude fields with None values. round_trip: Whether to output the serialized data in a way that is compatible with deserialization. warnings: How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors, "error" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError]. serialize_as_any: Whether to serialize fields with duck-typing serialization behavior. context: Additional context to pass to the serializer. Returns: The serialized object. """ > return self.serializer.to_python( instance, mode=mode, by_alias=by_alias, include=include, exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, exclude_none=exclude_none, round_trip=round_trip, warnings=warnings, serialize_as_any=serialize_as_any, context=context, ) E AttributeError: 'dict' object has no attribute 'comp_1' pydantic/type_adapter.py:451: AttributeError ____________________________________________________ test_presence_of_discriminator_when_generating_type_adaptor_json_schema_definitions ____________________________________________________ @pytest.mark.xfail(reason='Issue not yet fixed, see: https://github.com/pydantic/pydantic/issues/8271.') def test_presence_of_discriminator_when_generating_type_adaptor_json_schema_definitions() -> None: class ItemType(str, Enum): ITEM1 = 'item1' ITEM2 = 'item2' class CreateItem1(BaseModel): item_type: Annotated[Literal[ItemType.ITEM1], Field(alias='type')] id: int class CreateItem2(BaseModel): item_type: Annotated[Literal[ItemType.ITEM2], Field(alias='type')] id: int class CreateObjectDto(BaseModel): id: int items: List[ Annotated[ Union[ CreateItem1, CreateItem2, ], Field(discriminator='item_type'), ] ] adaptor = TypeAdapter( Annotated[CreateObjectDto, FieldInfo(examples=[{'id': 1, 'items': [{'id': 3, 'type': 'ITEM1'}]}])] ) schema_map, definitions = GenerateJsonSchema().generate_definitions([(adaptor, 'validation', adaptor.core_schema)]) > assert definitions == { 'CreateItem1': { 'properties': {'id': {'title': 'Id', 'type': 'integer'}, 'type': {'const': 'item1', 'title': 'Type'}}, 'required': ['type', 'id'], 'title': 'CreateItem1', 'type': 'object', }, 'CreateItem2': { 'properties': {'id': {'title': 'Id', 'type': 'integer'}, 'type': {'const': 'item2', 'title': 'Type'}}, 'required': ['type', 'id'], 'title': 'CreateItem2', 'type': 'object', }, 'CreateObjectDto': { 'properties': { 'id': {'title': 'Id', 'type': 'integer'}, 'items': { 'items': { 'discriminator': { 'mapping': {'item1': '#/$defs/CreateItem1', 'item2': '#/$defs/CreateItem2'}, 'propertyName': 'type', }, 'oneOf': [{'$ref': '#/$defs/CreateItem1'}, {'$ref': '#/$defs/CreateItem2'}], }, 'title': 'Items', 'type': 'array', }, }, 'required': ['id', 'items'], 'title': 'CreateObjectDto', 'type': 'object', }, } E AssertionError: assert {'CreateItem1...e': 'object'}} == {'CreateItem1...e': 'object'}} E E Differing items: E {'CreateItem2': {'properties': {'id': {'title': 'Id', 'type': 'integer'}, 'type': {'const': 'item2 E E ...Full output truncated (4 lines hidden), use '-vv' to show tests/test_discriminated_union.py:1837: AssertionError ____________________________________________________________________________ test_discriminated_union_serializer ____________________________________________________________________________ @pytest.mark.xfail(reason='Waiting for union serialization fixes via https://github.com/pydantic/pydantic/issues/9688.') def test_discriminated_union_serializer() -> None: """Reported via https://github.com/pydantic/pydantic/issues/9590.""" @dataclass class FooId: _id: int @dataclass class BarId: _id: int FooOrBarId = Annotated[ Annotated[FooId, PlainSerializer(lambda v: {'tag': 'foo', '_id': v._id}), Tag('foo')] | Annotated[BarId, PlainSerializer(lambda v: {'tag': 'bar', '_id': v._id}), Tag('bar')], Discriminator(lambda v: v['tag']), ] adapter = TypeAdapter(FooOrBarId) > assert adapter.dump_python(FooId(1)) == {'tag': 'foo', '_id': 1} tests/test_discriminated_union.py:2173: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pydantic/type_adapter.py:135: in wrapped return func(self, *args, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , instance = test_discriminated_union_serializer..FooId(_id=1) @_frame_depth(1) def dump_python( self, instance: T, /, *, mode: Literal['json', 'python'] = 'python', include: IncEx | None = None, exclude: IncEx | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal['none', 'warn', 'error'] = True, serialize_as_any: bool = False, context: dict[str, Any] | None = None, ) -> Any: """Dump an instance of the adapted type to a Python object. Args: instance: The Python object to serialize. mode: The output format. include: Fields to include in the output. exclude: Fields to exclude from the output. by_alias: Whether to use alias names for field names. exclude_unset: Whether to exclude unset fields. exclude_defaults: Whether to exclude fields with default values. exclude_none: Whether to exclude fields with None values. round_trip: Whether to output the serialized data in a way that is compatible with deserialization. warnings: How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors, "error" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError]. serialize_as_any: Whether to serialize fields with duck-typing serialization behavior. context: Additional context to pass to the serializer. Returns: The serialized object. """ > return self.serializer.to_python( instance, mode=mode, by_alias=by_alias, include=include, exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, exclude_none=exclude_none, round_trip=round_trip, warnings=warnings, serialize_as_any=serialize_as_any, context=context, ) E UserWarning: Pydantic serializer warnings: E Failed to get discriminator value for tagged union serialization with value `test_discriminated_union_...er..FooId(_id=1)` - defaulting to left to right union serialization. pydantic/type_adapter.py:451: UserWarning ___________________________________________________________________ test_generic_model_as_parameter_to_generic_type_alias ___________________________________________________________________ @pytest.mark.xfail(reason='Generic models are not type aliases', raises=TypeError) def test_generic_model_as_parameter_to_generic_type_alias() -> None: T = TypeVar('T') class GenericPydanticModel(BaseModel, Generic[T]): x: T GenericPydanticModelList = List[GenericPydanticModel[T]] > GenericPydanticModelList[int] tests/test_generics.py:2236: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib64/python3.10/typing.py:312: in inner return func(*args, **kwds) /usr/lib64/python3.10/typing.py:1058: in __getitem__ _check_generic(self, params, len(self.__parameters__)) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ cls = typing.List[tests.test_generics.test_generic_model_as_parameter_to_generic_type_alias..GenericPydanticModel], parameters = (,), elen = 0 def _check_generic(cls, parameters, elen=_marker): """Check correct count for parameters of a generic cls (internal helper). This gives a nice error message in case of count mismatch. """ if not elen: > raise TypeError(f"{cls} is not a generic class") E TypeError: typing.List[tests.test_generics.test_generic_model_as_parameter_to_generic_type_alias..GenericPydanticModel] is not a generic class /usr/lib/python3.10/site-packages/typing_extensions.py:2878: TypeError ____________________________________________________________________________ test_get_pydantic_core_schema_calls ____________________________________________________________________________ @pytest.mark.xfail( reason=( 'We are calling __get_pydantic_json_schema__ too many times.' ' The second time we analyze a model we get the CoreSchema from __pydantic_core_schema__.' ' But then we proceed to append to the metadata json schema functions.' ) ) def test_get_pydantic_core_schema_calls() -> None: """Verify when/how many times `__get_pydantic_core_schema__` gets called""" calls: List[str] = [] class Model(BaseModel): @classmethod def __get_pydantic_json_schema__(cls, schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue: calls.append('Model::before') json_schema = handler(schema) calls.append('Model::after') return json_schema schema = Model.model_json_schema() expected: JsonSchemaValue = {'type': 'object', 'properties': {}, 'title': 'Model'} assert schema == expected assert calls == ['Model::before', 'Model::after'] calls.clear() class CustomAnnotation(NamedTuple): name: str def __get_pydantic_json_schema__(self, schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue: calls.append(f'CustomAnnotation({self.name})::before') json_schema = handler(schema) calls.append(f'CustomAnnotation({self.name})::after') return json_schema AnnotatedType = Annotated[str, CustomAnnotation('foo'), CustomAnnotation('bar')] schema = TypeAdapter(AnnotatedType).json_schema() expected: JsonSchemaValue = {'type': 'string'} assert schema == expected assert calls == [ 'CustomAnnotation(bar)::before', 'CustomAnnotation(foo)::before', 'CustomAnnotation(foo)::after', 'CustomAnnotation(bar)::after', ] calls.clear() class OuterModel(BaseModel): x: Model @classmethod def __get_pydantic_json_schema__(cls, schema: CoreSchema, handler: GetJsonSchemaHandler) -> JsonSchemaValue: calls.append('OuterModel::before') json_schema = handler(schema) calls.append('OuterModel::after') return json_schema schema = OuterModel.model_json_schema() expected: JsonSchemaValue = { 'type': 'object', 'properties': {'x': {'$ref': '#/$defs/Model'}}, 'required': ['x'], 'title': 'OuterModel', '$defs': {'Model': {'type': 'object', 'properties': {}, 'title': 'Model'}}, } assert schema == expected assert calls == [ 'OuterModel::before', 'Model::before', 'Model::after', 'OuterModel::after', ] calls.clear() AnnotatedModel = Annotated[Model, CustomAnnotation('foo')] schema = TypeAdapter(AnnotatedModel).json_schema() expected: JsonSchemaValue = {} > assert schema == expected E AssertionError: assert {'properties'...pe': 'object'} == {} E E Left contains 3 more items: E {'properties': {}, 'title': 'Model', 'type': 'object'} E Use -v to get more diff tests/test_json_schema.py:4629: AssertionError ______________________________________________________________________________ test_model_validate_list_strict ______________________________________________________________________________ @pytest.mark.xfail( reason='strict=True in model_validate_json does not overwrite strict=False given in ConfigDict' 'See issue: https://github.com/pydantic/pydantic/issues/8930' ) def test_model_validate_list_strict() -> None: # FIXME: This change must be implemented in pydantic-core. The argument strict=True # in model_validate_json method is not overwriting the one set with ConfigDict(strict=False) # for sequence like types. See: https://github.com/pydantic/pydantic/issues/8930 class LaxModel(BaseModel): x: List[str] model_config = ConfigDict(strict=False) assert LaxModel.model_validate_json(json.dumps({'x': ('a', 'b', 'c')}), strict=None) == LaxModel(x=('a', 'b', 'c')) assert LaxModel.model_validate_json(json.dumps({'x': ('a', 'b', 'c')}), strict=False) == LaxModel(x=('a', 'b', 'c')) > with pytest.raises(ValidationError) as exc_info: E Failed: DID NOT RAISE tests/test_main.py:2447: Failed ______________________________________________________________________________ test_invalid_json_schema_raises ______________________________________________________________________________ args = (, {'metadata': {'pydantic_js_annotation_functions':...onSchema.__get_pydantic_json_schema__ of WithJsonSchema(json_schema={'type': 'invalid'}, mode=None)>]}, 'type': 'int'}) kwargs = {'mode': 'validation'}, json_schema = {'type': 'invalid'} def generate(*args: Any, **kwargs: Any) -> Any: json_schema = orig_generate(*args, **kwargs) if not request.node.get_closest_marker('skip_json_schema_validation'): try: > Draft202012Validator.check_schema(json_schema) tests/conftest.py:166: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ cls = , schema = {'type': 'invalid'} format_checker = @classmethod def check_schema(cls, schema, format_checker=_UNSET): Validator = validator_for(cls.META_SCHEMA, default=cls) if format_checker is _UNSET: format_checker = Validator.FORMAT_CHECKER validator = Validator( schema=cls.META_SCHEMA, format_checker=format_checker, ) for error in validator.iter_errors(schema): > raise exceptions.SchemaError.create_from(error) E jsonschema.exceptions.SchemaError: 'invalid' is not valid under any of the given schemas E E Failed validating 'anyOf' in metaschema['allOf'][3]['properties']['type']: E {'anyOf': [{'$ref': '#/$defs/simpleTypes'}, E {'items': {'$ref': '#/$defs/simpleTypes'}, E 'minItems': 1, E 'type': 'array', E 'uniqueItems': True}]} E E On schema['type']: E 'invalid' /usr/lib/python3.10/site-packages/jsonschema/validators.py:302: SchemaError During handling of the above exception, another exception occurred: @pytest.mark.xfail(reason='Invalid JSON Schemas are expected to fail.') def test_invalid_json_schema_raises() -> None: > TypeAdapter(Annotated[int, WithJsonSchema({'type': 'invalid'})]).json_schema() tests/test_meta.py:12: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pydantic/type_adapter.py:135: in wrapped return func(self, *args, **kwargs) pydantic/type_adapter.py:542: in json_schema return schema_generator_instance.generate(self.core_schema, mode=mode) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ args = (, {'metadata': {'pydantic_js_annotation_functions':...onSchema.__get_pydantic_json_schema__ of WithJsonSchema(json_schema={'type': 'invalid'}, mode=None)>]}, 'type': 'int'}) kwargs = {'mode': 'validation'}, json_schema = {'type': 'invalid'} def generate(*args: Any, **kwargs: Any) -> Any: json_schema = orig_generate(*args, **kwargs) if not request.node.get_closest_marker('skip_json_schema_validation'): try: Draft202012Validator.check_schema(json_schema) except SchemaError: > pytest.fail( 'Failed to validate the JSON Schema against the Draft 2020-12 spec. ' 'If this is expected, you can mark the test function with the `skip_json_schema_validation` ' 'marker. Note that this validation only takes place during tests, and is not active at runtime.' ) E Failed: Failed to validate the JSON Schema against the Draft 2020-12 spec. If this is expected, you can mark the test function with the `skip_json_schema_validation` marker. Note that this validation only takes place during tests, and is not active at runtime. tests/conftest.py:168: Failed _________________________________________ test_mongodsn_default_ports[mongodb+srv://user:pass@localhost/app-mongodb+srv://user:pass@localhost/app] __________________________________________ dsn = 'mongodb+srv://user:pass@localhost/app', expected = 'mongodb+srv://user:pass@localhost/app' @pytest.mark.parametrize( ('dsn', 'expected'), [ ('mongodb://user:pass@localhost/app', 'mongodb://user:pass@localhost:27017/app'), pytest.param( 'mongodb+srv://user:pass@localhost/app', 'mongodb+srv://user:pass@localhost/app', marks=pytest.mark.xfail( reason=( 'This case is not supported. ' 'Check https://github.com/pydantic/pydantic/pull/7116 for more details.' ) ), ), ], ) def test_mongodsn_default_ports(dsn: str, expected: str): class Model(BaseModel): dsn: MongoDsn m = Model(dsn=dsn) > assert str(m.dsn) == expected E AssertionError: assert 'mongodb+srv:...ost:27017/app' == 'mongodb+srv:...localhost/app' E E - mongodb+srv://user:pass@localhost/app E + mongodb+srv://user:pass@localhost:27017/app E ? ++++++ tests/test_networks.py:773: AssertionError _________________________________________________________________________________ test_validate_json_strict _________________________________________________________________________________ @pytest.mark.xfail(reason='Need to fix this in https://github.com/pydantic/pydantic/pull/5944') def test_validate_json_strict() -> None: class Model(TypedDict): x: int class ModelStrict(Model): __pydantic_config__ = ConfigDict(strict=True) # type: ignore > lax_validator = TypeAdapter(Model, config=ConfigDict(strict=False)) tests/test_type_adapter.py:241: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , type = .Model'> def __init__( self, type: Any, *, config: ConfigDict | None = None, _parent_depth: int = 2, module: str | None = None, ) -> None: """Initializes the TypeAdapter object. Args: type: The type associated with the `TypeAdapter`. config: Configuration for the `TypeAdapter`, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. _parent_depth: depth at which to search the parent namespace to construct the local namespace. module: The module that passes to plugin if provided. !!! note You cannot use the `config` argument when instantiating a `TypeAdapter` if the type you're using has its own config that cannot be overridden (ex: `BaseModel`, `TypedDict`, and `dataclass`). A [`type-adapter-config-unused`](../errors/usage_errors.md#type-adapter-config-unused) error will be raised in this case. !!! note The `_parent_depth` argument is named with an underscore to suggest its private nature and discourage use. It may be deprecated in a minor version, so we only recommend using it if you're comfortable with potential change in behavior / support. ??? tip "Compatibility with `mypy`" Depending on the type used, `mypy` might raise an error when instantiating a `TypeAdapter`. As a workaround, you can explicitly annotate your variable: ```py from typing import Union from pydantic import TypeAdapter ta: TypeAdapter[Union[str, int]] = TypeAdapter(Union[str, int]) # type: ignore[arg-type] ``` Returns: A type adapter configured for the specified `type`. """ if _type_has_config(type) and config is not None: > raise PydanticUserError( 'Cannot use `config` when the type is a BaseModel, dataclass or TypedDict.' ' These types can have their own config and setting the config via the `config`' ' parameter to TypeAdapter will not override it, thus the `config` you passed to' ' TypeAdapter becomes meaningless, which is probably not what you want.', code='type-adapter-config-unused', ) E pydantic.errors.PydanticUserError: Cannot use `config` when the type is a BaseModel, dataclass or TypedDict. These types can have their own config and setting the config via the `config` parameter to TypeAdapter will not override it, thus the `config` you passed to TypeAdapter becomes meaningless, which is probably not what you want. E E For further information visit https://errors.pydantic.dev/2.9/u/type-adapter-config-unused pydantic/type_adapter.py:231: PydanticUserError ________________________________________________________________________________________ test_field _________________________________________________________________________________________ @pytest.mark.xfail(reason='description is currently dropped') def test_field() -> None: SomeAlias = TypeAliasType('SomeAlias', Annotated[int, Field(description='number')]) ta = TypeAdapter(Annotated[SomeAlias, Field(title='abc')]) # insert_assert(ta.json_schema()) > assert ta.json_schema() == { '$defs': {'SomeAlias': {'type': 'integer', 'description': 'number'}}, '$ref': '#/$defs/SomeAlias', 'title': 'abc', } E AssertionError: assert {'$defs': {'S...title': 'abc'} == {'$defs': {'S...title': 'abc'} E E Omitting 2 identical items, use -vv to show E Differing items: E {'$defs': {'SomeAlias': {'type': 'integer'}}} != {'$defs': {'SomeAlias': {'description': 'number', ' E E ...Full output truncated (2 lines hidden), use '-vv' to show tests/test_type_alias_type.py:325: AssertionError _______________________________________________________________________________ test_import_string_sys_stdout _______________________________________________________________________________ @pytest.mark.xfail( reason='This fails with pytest bc of the weirdness associated with importing modules in a test, but works in normal usage' ) def test_import_string_sys_stdout() -> None: class ImportThings(BaseModel): obj: ImportString import_things = ImportThings(obj='sys.stdout') > assert import_things.model_dump_json() == '{"obj":"sys.stdout"}' E assert '{"obj":null}' == '{"obj":"sys.stdout"}' E E - {"obj":"sys.stdout"} E + {"obj":null} tests/test_types.py:1052: AssertionError _______________________________________________________________________ test_plain_validator_with_filter_dict_schema ________________________________________________________________________ @pytest.mark.xfail(reason='https://github.com/pydantic/pydantic/issues/10428') def test_plain_validator_with_filter_dict_schema() -> None: class MyDict: @classmethod def __get_pydantic_core_schema__(cls, source, handler): return core_schema.dict_schema( keys_schema=handler.generate_schema(str), values_schema=handler.generate_schema(int), serialization=core_schema.filter_dict_schema( include={'a'}, ), ) > class Model(BaseModel): tests/test_validators.py:2905: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ pydantic/_internal/_model_construction.py:224: in __new__ complete_model_class( pydantic/_internal/_model_construction.py:587: in complete_model_class schema = gen_schema.clean_schema(schema) pydantic/_internal/_generate_schema.py:595: in clean_schema schema = validate_core_schema(schema) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ schema = {'cls': .Model'>, 'config': {'title...c_json_schema__ of .Model'>>]}, ...} def validate_core_schema(schema: CoreSchema) -> CoreSchema: if 'PYDANTIC_SKIP_VALIDATING_CORE_SCHEMAS' in os.environ: return schema > return _validate_core_schema(schema) E pydantic_core._pydantic_core.SchemaError: Invalid Schema: E model.schema.model-fields.fields.f.schema.function-plain.serialization E Input tag 'include-exclude-dict' found using 'type' does not match any of the expected tags: 'none', 'int', 'bool', 'float', 'str', 'bytes', 'bytearray', 'list', 'tuple', 'set', 'frozenset', 'generator', 'dict', 'datetime', 'date', 'time', 'timedelta', 'url', 'multi-host-url', 'json', 'uuid', 'any', 'function-plain', 'function-wrap', 'format', 'to-string', 'model' [type=union_tag_invalid, input_value={'type': 'include-exclude-dict', 'include': {'a'}}, input_type=dict] pydantic/_internal/_core_utils.py:570: SchemaError ================================================================================== short test summary info ================================================================================== SKIPPED [51] tests/mypy/test_mypy.py:167: Test only with "--test-mypy" flag SKIPPED [2] tests/mypy/test_mypy.py:167: Need to handle some more things for mypy >=1.1.1 SKIPPED [1] tests/mypy/test_mypy.py:223: Test only with "--test-mypy" flag SKIPPED [3] tests/mypy/test_mypy.py:246: Test only with "--test-mypy" flag SKIPPED [1] tests/mypy/test_mypy.py:256: Test only with "--test-mypy" flag SKIPPED [1] tests/mypy/test_mypy.py:268: Test only with "--test-mypy" flag SKIPPED [3] tests/mypy/test_mypy.py:275: Test only with "--test-mypy" flag SKIPPED [1] tests/plugin/test_plugin.py:8: Test only with `TEST_PLUGIN` env var set. SKIPPED [1] tests/test_abc.py:14: error value different on older versions SKIPPED [3] tests/test_computed_fields.py:527: error message is different on older versions SKIPPED [1] tests/test_computed_fields.py:786: waiting on next pydantic-core version, right now, causes a recursion error SKIPPED [1] tests/test_config.py:541: requires backport pre 3.11, fully tested in pydantic core SKIPPED [1] tests/test_dataclasses.py:2062: stdlib dataclasses don't support Pydantic fields SKIPPED [94] tests/test_docs.py:145: devtools not installed SKIPPED [491] tests/test_docs.py:168: devtools not installed SKIPPED [1] tests/test_docs.py:187: devtools not installed SKIPPED [1] tests/test_edge_cases.py:1544: difference in __name__ between versions SKIPPED [3] tests/test_edge_cases.py:2334: error message different on older versions SKIPPED [1] tests/test_generics.py:781: repr different on older versions SKIPPED [1] tests/test_generics.py:1033: Depends on similar issue in CPython itself: https://github.com/python/cpython/issues/86483 Documented and skipped for possible fix later. SKIPPED [1] tests/test_generics.py:2181: memray not enabled SKIPPED [1] tests/test_generics.py:2479: requires python 3.11 or higher SKIPPED [1] tests/test_generics.py:2515: requires python 3.11 or higher SKIPPED [1] tests/test_generics.py:2546: Multiple inheritance with NamedTuple and the corresponding type annotations aren't supported before Python 3.11 SKIPPED [1] tests/test_internal.py:186: could not import 'devtools': No module named 'devtools' SKIPPED [1] tests/test_json_schema.py:6237: TypedDict does not generate a DeprecationWarning on usage SKIPPED [21] tests/test_main.py:1432: not implemented SKIPPED [1] tests/test_main.py:1494: not implemented SKIPPED [1] tests/test_main.py:1518: not implemented SKIPPED [1] tests/test_main.py:1534: not implemented SKIPPED [1] tests/test_main.py:1561: not implemented SKIPPED [1] tests/test_model_signature.py:172: repr different on older versions SKIPPED [1] tests/test_networks.py:973: email_validator is installed SKIPPED [3] tests/test_titles.py:206: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [8] tests/test_titles.py:219: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [4] tests/test_titles.py:246: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [4] tests/test_titles.py:281: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [2] tests/test_titles.py:339: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [6] tests/test_titles.py:405: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [6] tests/test_titles.py:433: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [12] tests/test_titles.py:463: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types.py:885: different output SKIPPED [1] tests/test_types.py:1911: email_validator is installed SKIPPED [1] tests/test_types.py:1919: email_validator is installed SKIPPED [1] tests/test_types_self.py:27: Self is not available from SKIPPED [1] tests/test_types_self.py:35: Self is not available from SKIPPED [1] tests/test_types_self.py:47: Self is not available from SKIPPED [1] tests/test_types_self.py:68: Self is not available from SKIPPED [1] tests/test_types_self.py:85: Self is not available from SKIPPED [1] tests/test_types_self.py:108: Self is not available from SKIPPED [1] tests/test_types_self.py:117: Self is not available from SKIPPED [1] tests/test_types_self.py:142: Self is not available from SKIPPED [1] tests/test_types_self.py:151: Self is not available from SKIPPED [1] tests/test_types_self.py:160: Self is not available from SKIPPED [2] tests/test_types_typeddict.py:91: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:91: Required and NotRequired are not available from SKIPPED [2] tests/test_types_typeddict.py:111: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:111: Required and NotRequired are not available from SKIPPED [1] tests/test_types_typeddict.py:127: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:147: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:172: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:186: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:215: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:307: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [2] tests/test_types_typeddict.py:318: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:318: Required and NotRequired are not available from SKIPPED [2] tests/test_types_typeddict.py:379: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:379: Required and NotRequired are not available from SKIPPED [2] tests/test_types_typeddict.py:408: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:408: Required and NotRequired are not available from SKIPPED [1] tests/test_types_typeddict.py:443: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [3] tests/test_types_typeddict.py:472: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:716: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:740: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:751: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:805: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:824: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_types_typeddict.py:848: typing.TypedDict does not support all pydantic features in Python < 3.12 SKIPPED [1] tests/test_typing.py:127: testing using a feature not supported by older Python SKIPPED [1] tests/test_utils.py:309: devtools not installed SKIPPED [1] tests/test_validate_call.py:821: requires Python 3.12+ for PEP 695 syntax with generics XFAIL tests/test_computed_fields.py::test_multiple_references_to_schema[make_typed_dict] - computed fields do not work with TypedDict yet. See https://github.com/pydantic/pydantic-core/issues/657 XFAIL tests/test_discriminated_union.py::test_presence_of_discriminator_when_generating_type_adaptor_json_schema_definitions - Issue not yet fixed, see: https://github.com/pydantic/pydantic/issues/8271. XFAIL tests/test_discriminated_union.py::test_discriminated_union_serializer - Waiting for union serialization fixes via https://github.com/pydantic/pydantic/issues/9688. XFAIL tests/test_generics.py::test_generic_model_as_parameter_to_generic_type_alias - Generic models are not type aliases XFAIL tests/test_json_schema.py::test_get_pydantic_core_schema_calls - We are calling __get_pydantic_json_schema__ too many times. The second time we analyze a model we get the CoreSchema from __pydantic_core_schema__. But then we proceed to append to the metadata json schema functions. XFAIL tests/test_main.py::test_model_validate_list_strict - strict=True in model_validate_json does not overwrite strict=False given in ConfigDictSee issue: https://github.com/pydantic/pydantic/issues/8930 XFAIL tests/test_meta.py::test_invalid_json_schema_raises - Invalid JSON Schemas are expected to fail. XFAIL tests/test_networks.py::test_mongodsn_default_ports[mongodb+srv://user:pass@localhost/app-mongodb+srv://user:pass@localhost/app] - This case is not supported. Check https://github.com/pydantic/pydantic/pull/7116 for more details. XFAIL tests/test_type_adapter.py::test_validate_json_strict - Need to fix this in https://github.com/pydantic/pydantic/pull/5944 XFAIL tests/test_type_alias_type.py::test_field - description is currently dropped XFAIL tests/test_types.py::test_import_string_sys_stdout - This fails with pytest bc of the weirdness associated with importing modules in a test, but works in normal usage XFAIL tests/test_validators.py::test_plain_validator_with_filter_dict_schema - https://github.com/pydantic/pydantic/issues/10428 FAILED tests/test_json.py::test_subclass_custom_encoding - pydantic_core._pydantic_core.SchemaError: Invalid Schema: FAILED tests/test_json_schema.py::test_model_default_timedelta[float-properties0] - pydantic_core._pydantic_core.SchemaError: Invalid Schema: FAILED tests/test_json_schema.py::test_dataclass_default_timedelta[float-properties0] - pydantic_core._pydantic_core.SchemaError: Invalid Schema: FAILED tests/test_json_schema.py::test_typeddict_default_timedelta[float-properties0] - pydantic_core._pydantic_core.SchemaError: Invalid Schema: ================================================================= 4 failed, 5087 passed, 787 skipped, 12 xfailed in 34.61s ================================================================== ```
sydney-runkle commented 1 month ago

What version of pydantic-core are you using?

sydney-runkle commented 1 month ago

Looks like you're pulling pydantic from main without the most recent pydantic-core version. Closing as resolved for now. Happy to reopen if you're still experiencing issues after that.

kloczek commented 1 month ago

But pydantic-core 2.24.0 is recent version 🤔

sydney-runkle commented 1 month ago

Right but it's not compatible with v2.9.2