Closed lostb1t closed 4 years ago
I think it is a bug, thank you, I will fix it.
The situation is more complex than I expected, the root cause is that Pygrahy check validations at the type definition time. However, Python load definitions sequential, it means WhereInput
is not in the context when Pygraphy starts to check it.
I will think about how to fix it, maybe we can make validation lazy, after all types have been initialized.
yeah, resolving forward refs after class creation or make them lazy might work. Pydantic does something similar: https://pydantic-docs.helpmanual.io/usage/postponed_annotations/
Lazy loading should be cleaner though instead of having to call a resolve function manually.
I fixed it, but according to the behavior of Python, we have to take care of definition sequences, I wrote a test case to explain it: https://github.com/ethe/pygraphy/blob/85745100c7af4981305eae1b7abb2c0ba7e8b1c8/tests/test_recursive_def.py
Thank you, if you have any other suggestions and bug reporting, please let me know, I will be glad to improve Pygraphy.
Currently this results in a recursive error
Example code (python 3.7+):
Error output: