Skip to content

Support Python 3.14 / Update Pydantic #3831

@meeuw

Description

@meeuw

Python 3.14 has been released and I've tried running the build.yml workflow but it seems to fail with the following error message:

make pr
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.14.0/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.14.0/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.14.0/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.14.0/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.14.0/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.14.0/x64/lib
# Checking latest schema was generated (run `make schema` if this fails)
mkdir -p .tmp
python -m samtranslator.internal.schema_source.schema --sam-schema .tmp/sam.schema.json --cfn-schema schema_source/cloudformation.schema.json --unified-schema .tmp/schema.json
/home/runner/work/serverless-application-model/serverless-application-model/samtranslator/compat.py:2: UserWarning: Core Pydantic V1 functionality isn't compatible with Python 3.14 or greater.
  from pydantic import v1 as pydantic
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/runner/work/serverless-application-model/serverless-application-model/samtranslator/internal/schema_source/schema.py", line 10, in <module>
    from samtranslator.internal.schema_source import (
    ...<10 lines>...
    )
  File "/home/runner/work/serverless-application-model/serverless-application-model/samtranslator/internal/schema_source/aws_serverless_api.py", line 5, in <module>
    from samtranslator.internal.schema_source.aws_serverless_connector import EmbeddedConnector
  File "/home/runner/work/serverless-application-model/serverless-application-model/samtranslator/internal/schema_source/aws_serverless_connector.py", line 16, in <module>
    class ResourceReference(BaseModel):
    ...<7 lines>...
        Type: Optional[str] = resourcereference("Type")
  File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/pydantic/v1/main.py", line 221, in __new__
    inferred = ModelField.infer(
        name=var_name,
    ...<3 lines>...
        config=config,
    )
  File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/pydantic/v1/fields.py", line 504, in infer
    return cls(
        name=name,
    ...<7 lines>...
        field_info=field_info,
    )
  File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/pydantic/v1/fields.py", line 434, in __init__
    self.prepare()
    ~~~~~~~~~~~~^^
  File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/pydantic/v1/fields.py", line 555, in prepare
    self.populate_validators()
    ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/pydantic/v1/fields.py", line 829, in populate_validators
    *(get_validators() if get_validators else list(find_validators(self.type_, self.model_config))),
                                              ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/pydantic/v1/validators.py", line 768, in find_validators
    raise RuntimeError(f'no validator found for {type_}, see `arbitrary_types_allowed` in Config')
RuntimeError: no validator found for <class 'pydantic.v1.fields.UndefinedType'>, see `arbitrary_types_allowed` in Config
make: *** [Makefile:37: format-check] Error 1
Error: Process completed with exit code 2.

Pydantic V1 is not compatible with Python 3.14 and greater so I think the serverless-application-model need to update to Pydantic V2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions