Ed-XCF / protobuf2pydantic

generate pydantic model by protobuf.pb2 file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error running CLI - unsupported operand type(s)

asafalina opened this issue · comments

Hi

I think there's some issue with the CLI.
I did the following:

python3.9 -m venv .venv
source .venv/bin/activate
pip3 install protobuf2pydantic
pb2py --help 

and I got:

Traceback (most recent call last):
  File "/Users/my_user/repos/tmp/.venv/bin/pb2py", line 5, in <module>
    from protobuf2pydantic.main import app
  File "/Users/my_user/repos/tmp/.venv/lib/python3.9/site-packages/protobuf2pydantic/__init__.py", line 11, in <module>
    from protobuf2pydantic.biz import msg2pydantic
  File "/Users/my_user/repos/tmp/.venv/lib/python3.9/site-packages/protobuf2pydantic/biz.py", line 64, in <module>
    def convert_field(level: int, field: FieldDescriptor) -> str | None:
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

I'm getting a similar error when I run pb2py /path/to/protobuf/dummy_pb2.py > wow.py command, and when I simply import protobuf2pydantic.

Note the issue seem to exist in the newest version only, 2024.1.8.
The version one before it 2023.12.21 seem to be working fine.

I'm using Python 3.9.13, on a Mac with Sonoma 14.1 OS, with protobuf2pydantic version 2024.1.8

opened a PR to fix the issue.