Skip to content

Exception thrown when running with Pydantic 2.12 #110

@tjstjsgt

Description

@tjstjsgt

Describe the bug
Exception thrown during generation.

Dependencies

Input cmd:

python -m protobuf_to_pydantic --info

Result:

current working directory:  [REDACTED]
python version: sys.version_info(major=3, minor=14, micro=0, releaselevel='final', serial=0)

############# dependencies ############## 
    grpc:            Not Install
    pydantic:        2.12.0

########## Expand dependencies ########## 
    mypy-protobuf:   3.5.0
    toml:            Not Install

########## Format dependencies ########## 
    autoflake:       Not Install
    black:           Not Install
    isort:           Not Install

Protobuf File Content

Filename: proto/demo1.proto

package demo1;

message Demo1{};

CLI(if use plugin mode)

mkdir out
protoc --proto_path=./proto \
--python_out=out \
--pyi_out=out \
--protobuf-to-pydantic_out=out \
./proto/demo.proto 

Output content

'pydantic_core._pydantic_core.ValidationInfo' object has no attribute 'template'
Traceback (most recent call last):
  File "[REDACTED]/python3.14/site-packages/protobuf_to_pydantic/plugin/main.py", line 14, in main
    CodeGen(ConfigModel)
    ~~~~~~~^^^^^^^^^^^^^
  File "[REDACTED]/python3.14/site-packages/protobuf_to_pydantic/plugin/code_gen.py", line 32, in __init__
    self.gen_config()
    ~~~~~~~~~~~~~~~^^
  File "[REDACTED]/python3.14/site-packages/protobuf_to_pydantic/plugin/code_gen.py", line 141, in gen_config
    self.config = self.config_class()
                  ~~~~~~~~~~~~~~~~~^^
  File "[REDACTED]/python3.14/site-packages/pydantic/main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
  File "[REDACTED]/python3.14/site-packages/protobuf_to_pydantic/plugin/config.py", line 145, in after_init
    values.template_instance = values.template(values.local_dict, values.comment_prefix)
                               ^^^^^^^^^^^^^^^
AttributeError: 'pydantic_core._pydantic_core.ValidationInfo' object has no attribute 'template'

Expected behavior
Protos generated as normal

Screenshots
N/A

Additional context
Working with Pydantic 2.11, started occurring with Pydantic 2.12 update

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions