-
Notifications
You must be signed in to change notification settings - Fork 44
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
forward_refs updates not running in all classes that need it #27
Comments
I tried changing The reason is b/c |
That sounds good. To be honest, I did my patch keeping as much of the original code (e.g. isinstance()) as possible. And in this case the assumption was that the "update_forward_refs" property was available to be called which is what I tested for. |
@agostof when I try your fix I get an error:
|
If anyone is still looking into using this, then the proper patch is this: Edit file if model[1].__module__ == "@[email protected]":
model_class = model[1]
if isinstance(model_class, BaseModel) or hasattr(model_class, "update_forward_refs"):
try:
model_class.update_forward_refs()
except Exception:
pass |
The current package-level __init__.py is buggy and doesn't correctly identify classes to call update_forward_refs() on. We're currently replacing this file at a later stage, but it would be better to generate it correctly. See also the upstream issue: dmontagu#27
When running a simple example client I get the following error:
It seems that the initialization code in
client/__init__.py
is not finding all the classes that need the fwd_refs to be updated.My solution was to run update_forward_refs in all classes (
openapi-python-templates/__init__package.mustache
)The text was updated successfully, but these errors were encountered: