- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 105
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
When running Python v3.14, Polyfactory fails to run Pydantic factories due to upstream changes in Pydantic v2.12. The newest Pydantic version now throws a UserWarning when trying to import Pydantic v1. The relevant PR is: pydantic/pydantic#12367
Polyfactory attempts to load pydantic v1 on line 85 of factories/pydantic_factory.py in a try/except block that now fails instead of the expected behavior of loading Pydantic v2.
URL to code causing the issue
No response
MCVE
Steps to reproduce
Screenshots
Logs
File "/Users/user/repos/vapi2/.venv/lib/python3.14/site-packages/polyfactory/__init__.py", line 2, in <module>
    from .factories import BaseFactory
  File "/Users/user/repos/vapi2/.venv/lib/python3.14/site-packages/polyfactory/factories/__init__.py", line 1, in <module>
    from polyfactory.factories.base import BaseFactory
  File "/Users/user/repos/vapi2/.venv/lib/python3.14/site-packages/polyfactory/factories/base.py", line 1270, in <module>
    _register_builtin_factories()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/user/repos/vapi2/.venv/lib/python3.14/site-packages/polyfactory/factories/base.py", line 1265, in _register_builtin_factories
    import_module(module)
    ~~~~~~~~~~~~~^^^^^^^^
  File "/Users/user/.local/share/uv/python/cpython-3.14.0-macos-aarch64-none/lib/python3.14/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/repos/vapi2/.venv/lib/python3.14/site-packages/polyfactory/factories/pydantic_factory.py", line 85, in <module>
    import pydantic.v1 as pydantic_v1  # type: ignore[no-redef]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/repos/vapi2/.venv/lib/python3.14/site-packages/pydantic/v1/__init__.py", line 138, in <module>
    warnings.warn(
    ~~~~~~~~~~~~~^
        "Core Pydantic V1 functionality isn't compatible with Python 3.14 or greater.",
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        UserWarning,
        ^^^^^^^^^^^^
        stacklevel=2,
        ^^^^^^^^^^^^^
    )
    ^
UserWarning: Core Pydantic V1 functionality isn't compatible with Python 3.14 or greater.Release Version
2.22.2
Platform
- Linux
- Mac
- Windows
- Other (Please specify in the description above)
jodal and MRigal
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working