8000 RecursionError: maximum recursion depth exceeded in comparison in _abc_instancecheck(cls, instance) · Issue #57 · so1n/protobuf_to_pydantic · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

RecursionError: maximum recursion depth exceeded in comparison in _abc_instancecheck(cls, instance) #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tirth7777777 opened this issue Jun 13, 2024 · 1 comment · Fixed by #59
Assignees

Comments

@tirth7777777
Copy link
tirth7777777 commented Jun 13, 2024

Describe the bug
I got the error

    _content_tuple: Optional[Tuple[str, str]] = self._message_field_handle(
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 200, in _message_field_handle
    self._message(message, root_desc, [FileDescriptorProto.ENUM_TYPE_FIELD_NUMBER])
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 487, in _message
    _content_tuple: Optional[Tuple[str, str]] = self._message_field_handle(
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 200, in _message_field_handle
    self._message(message, root_desc, [FileDescriptorProto.ENUM_TYPE_FIELD_NUMBER])
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 487, in _message
    _content_tuple: Optional[Tuple[str, str]] = self._message_field_handle(
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 200, in _message_field_handle
    self._message(message, root_desc, [FileDescriptorProto.ENUM_TYPE_FIELD_NUMBER])
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 487, in _message
    _content_tuple: Optional[Tuple[str, str]] = self._message_field_handle(
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 200, in _message_field_handle
    self._message(message, root_desc, [FileDescriptorProto.ENUM_TYPE_FIELD_NUMBER])
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 487, in _message
    _content_tuple: Optional[Tuple[str, str]] = self._message_field_handle(
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 200, in _message_field_handle
    self._message(message, root_desc, [FileDescriptorProto.ENUM_TYPE_FIELD_NUMBER])
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 487, in _message
    _content_tuple: Optional[Tuple[str, str]] = self._message_field_handle(
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 200, in _message_field_handle
    self._message(message, root_desc, [FileDescriptorProto.ENUM_TYPE_FIELD_NUMBER])
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 487, in _message
    _content_tuple: Optional[Tuple[str, str]] = self._message_field_handle(
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 221, in _message_field_handle
    protobuf_type_model = self._get_protobuf_type_model(field)
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/plugin/field_desc_proto_to_code.py", line 577, in _get_protobuf_type_model
    py_type_str=self._get_value_code(type_factory),
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/gen_code.py", line 217, in _get_value_code
    type_ = replace_protobuf_type_to_python_type(type_)
  File "/Users/tirth/work/bicycle-ai/venv/lib/python3.10/site-packages/protobuf_to_pydantic/util.py", line 77, in replace_protobuf_type_to_python_type
    elif isinstance(value, (list, *ProtobufRepeatedType)):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/abc.py", line 119, in __instancecheck__
    return _abc_instancecheck(cls, instance)
RecursionError: maximum recursion depth exceeded in comparison

To Reproduce

syntax = "proto3";
package temp.test;
message InvoiceItem2 {
  string name = 1;
  int32 amount = 2;
  int32 quantity = 3;
  repeated InvoiceItem2 items = 4;
  Invoice3 invoice = 5;
}

message Invoice3 {
  string name = 1;
  int32 amount = 2;
  int32 quantity = 3;
  repeated InvoiceItem2 items = 4;
}

I tried converting the proto to pydantic classes using
python -m grpc_tools.protoc -I./testProto --python_out=./testProto ./testProto/temp2.proto

It can also be reproduced by

from protobuf_to_pydantic import msg_to_pydantic_model

from testProto.temp2_pb2 import Invoice3

model = msg_to_pydantic_model(Invoice3)

Expected behavior
Pydantic classes to be generated

@so1n so1n self-assigned this Jun 13, 2024
@terrypireaux
Copy link

Also repeatable if running with imports included like buf generate --template buf.gen.python.yaml --include-imports

so1n added a commit that referenced this issue Jul 23, 2024
…depth-exceeded-in-comparison-in-_abc_instancecheckcls-instance

Fix(#57), Fix the inability to parse  a circularly referenced Message
@so1n so1n closed this as completed in #59 Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0