Expected behavior
Exactly what happened, except we should then be able to import and use the generated classes. Instead, an AttributeError is raised.
Version:
OS: MacOS 14.3.1 (23D60)
Python version: 3.12.3
Pydantic version: 2.7.2
datamodel-code-generator version: 0.25.6
Additional context
In the generated file src/bean.py, if we manually change from . import bean_type to from .bean_type import BeanType, and the corresponding usage in the Bean class definition, the error disappears. Might be related to #1683 / #1684
Describe the bug Generating from a schema with an Enum type causes
AttributeError: 'FieldInfo' object has no attribute '<EnumName>'
To Reproduce File structure after codegen should look like:
With the schemas defined as follows:
schemas/bean.json
schemas/bean_type.json
and
main.py
Used commandline
Expected behavior Exactly what happened, except we should then be able to import and use the generated classes. Instead, an AttributeError is raised.
Version:
Additional context In the generated file
src/bean.py
, if we manually changefrom . import bean_type
tofrom .bean_type import BeanType
, and the corresponding usage in theBean
class definition, the error disappears. Might be related to #1683 / #1684