Closed
Description
In python 3.7
, I am encountering a infinite recursive loop when using the generated code. Here is a simple example.
@dataclass
class EsriTypesesriShapeBuffer(betterproto.Message):
bytes: bytes = betterproto.bytes_field(1)
In the core dataclass module, the Field
class causes recursion error here:
def __repr__(self):
return (
'Field('
f'name={self.name!r},'
f'type={self.type!r},' # problem value `self.type`
f'default={self.default!r},'
f'default_factory={self.default_factory!r},'
f'init={self.init!r},'
f'repr={self.repr!r},'
f'hash={self.hash!r},'
f'compare={self.compare!r},'
f'metadata={self.metadata!r},'
f'_field_type={self._field_type}'
')'
)
The part causing the error is this: f'type={self.type!r},'
If I comment out the self.type
or monkey patch it in the generated dataclass
from the tool.
Here is a work around:
def __repr__monkey__(self, **kwargs):
return (
'Field('
f'name={self.name!r},'
# f'type={self.type!r},'
f'default={self.default!r},'
f'default_factory={self.default_factory!r},'
f'init={self.init!r},'
f'repr={self.repr!r},'
f'hash={self.hash!r},'
f'compare={self.compare!r},'
f'metadata={self.metadata!r},'
f'_field_type={self._field_type}'
')'
)
Field.__repr__ = __repr__monkey__
I don't know enough about what self.type should be to determine the proper fix, but the monkey patch will get you in the right direction.
Metadata
Metadata
Assignees
Labels
No labels