-
Notifications
You must be signed in to change notification settings - Fork 211
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
Using Pydantic creates circular imports #598
Comments
I think that the problem can be solved by moving some imports to the end of the generated files, just before all the Or should we consider that circular package dependencies are not acceptable and should indeed produce an error? As far as I know, they work correctly with the original gRPC python client and betterproto without pydantic, but I'm not sure about the other clients. |
There's no reason for them not to work. Please if you do fix this add a test so this doesn't happen in the future. |
Great, thanks! Actually, it seems that there is already a test for that: If I replace |
Actually, I have the impression that it is not that simple to fix. I tried putting the imports from After I fixed that quickly by adding a prefix, in my project, I still had errors occurring during the calls to |
In the end, I probably have a solution. I will test it, and if it works, I will send a PR once the other issues that I opened are fixed (I need the fix to solve this problem) |
Summary
Using Pydantic creates circular imports
Reproduction Steps
Compile the following
.proto
files:A_a.proto
:A_b.proto
:B.proto
:There is no circular dependency between the
.proto
files. However, after the compilation, there is a circular dependency between the two packages.Expected Results
I compiled the
.proto
files with thepydantic_dataclasses
.I would expect importing the library with
import root.apackage
to work correctly.Actual Results
import root.apackage
fails with the following error:System Information
Checklist
pip install -U --pre betterproto
, if possible.Notes
When Pydantic is not used, the circular dependency is handled correctly by Python.
The text was updated successfully, but these errors were encountered: