You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This results in a generated directory that looks like
Foo.py
Bar.py
A Foo.py that looks like
classFoo(BaseModel):
# ...
And a Bar.py that looks like
from . importFooclassBar(BaseModel):
foo: Optional[Foo] =None
I then package this module and publish it on a private repo. When I try to use it in another project, I get the following error
TypeError: typing.Optional requires a single type. Got <module 'Foo'> from '...'
I believe this error happens because the module and class have the same name. If i try again, but rename the module to Foo2.py, then the genereated Bar.py looks like
from . importFoo2classBar(BaseModel):
foo: Optional[Foo2.Foo] =None
And there's no error
Expected behavior
The Foo class should be used for typing instead of the Foo module.
Version:
OS: Mac OSX Sonoma 14.4
Python version: 3.9
datamodel-code-generator version: 0.25.2
The text was updated successfully, but these errors were encountered:
Describe the bug
I have a directory of json schemas that cannot be modified. Inside this directory, there are several files with the following layout:
This results in a generated directory that looks like
A Foo.py that looks like
And a Bar.py that looks like
I then package this module and publish it on a private repo. When I try to use it in another project, I get the following error
I believe this error happens because the module and class have the same name. If i try again, but rename the module to
Foo2.py
, then the genereatedBar.py
looks likeAnd there's no error
Expected behavior
The
Foo
class should be used for typing instead of theFoo
module.Version:
The text was updated successfully, but these errors were encountered: