Skip to content

DeprecationWarning for field_name argument on with_info_after_validator_function raises #345

@dvzrv

Description

@dvzrv

Hi! 👋

I'm maintaining this project as a package for Arch Linux.

With 2.10.6 I'm running into issues with the tests against pydantic 2.12.0 + pydantic-core 2.41.1 and pydantic 2.12.2 + pydantic-core 2.41.4:

============================= test session starts ==============================
platform linux -- Python 3.13.7, pytest-8.4.2, pluggy-1.6.0 -- /usr/bin/python
cachedir: .pytest_cache
rootdir: /build/python-pydantic-extra-types/src/pydantic-extra-types-2.10.6
configfile: pyproject.toml
plugins: time-machine-2.19.0
collecting ... collected 13306 items / 1 error

==================================== ERRORS ====================================
______________________ ERROR collecting tests/test_s3.py _______________________
tests/test_s3.py:7: in <module>
    class S3Check(BaseModel):
/usr/lib/python3.13/site-packages/pydantic/_internal/_model_construction.py:255: in __new__
    complete_model_class(
/usr/lib/python3.13/site-packages/pydantic/_internal/_model_construction.py:648: in complete_model_class
    schema = gen_schema.generate_schema(cls)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py:729: in generate_schema
    schema = self._generate_schema_inner(obj)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py:1023: in _generate_schema_inner
    return self._model_schema(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py:856: in _model_schema
    {k: self._generate_md_field_schema(k, v, decorators) for k, v in fields.items()},
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py:1228: in _generate_md_field_schema
    schema, metadata = self._common_field_schema(name, field_info, decorators)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py:1282: in _common_field_schema
    schema = self._apply_annotations(
/usr/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py:2227: in _apply_annotations
    schema = get_inner_schema(source_type)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.13/site-packages/pydantic/_internal/_schema_generation_shared.py:83: in __call__
    schema = self._handler(source_type)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py:2203: in inner_handler
    schema = self._generate_schema_from_get_schema_method(obj, source_type)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py:919: in _generate_schema_from_get_schema_method
    schema = get_schema(
pydantic_extra_types/s3.py:65: in __get_pydantic_core_schema__
    return core_schema.with_info_after_validator_function(
/usr/lib/python3.13/site-packages/pydantic_core/core_schema.py:2227: in with_info_after_validator_function
    warnings.warn(
E   DeprecationWarning: The `field_name` argument on `with_info_after_validator_function` is deprecated, it will be passed to the function through `ValidationState` instead.
=========================== short test summary info ============================
ERROR tests/test_s3.py - DeprecationWarning: The `field_name` argument on `with_info_after_validator_function` is deprecated, it will be passed to the function through `ValidationState` instead.
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.52s ===============================

If I ignore the DeprecationWarning (which is raised as error) I'm able to run tests.

cc @christian-heusel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions