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
Circular dependency while generating from OGC WFS XSD #941
Comments
Circular includes in schemas are very common which leads to circular import errors in python. There is an option though to change the file structure output. See here The default value is to follow the ❯ xsdata generate https://raw.githubusercontent.com/highsource/ogc-schemas/master/schemas/src/main/resources/ogc/wfs/2.0/wfs.xsd -ss clusters
========= xsdata v24.1 / Python 3.11.4+ / Platform linux =========
Parsing schema https://raw.githubusercontent.com/highsource/ogc-schemas/master/schemas/src/main/resources/ogc/wfs/2.0/wfs.xsd
Parsing schema file:///home/chris/.pyenv/versions/3.11-dev/envs/xsdata/lib/python3.11/site-packages/xsdata/schemas/xml.xsd
Compiling schema file:///home/chris/.pyenv/versions/3.11-dev/envs/xsdata/lib/python3.11/site-packages/xsdata/schemas/xml.xsd
Builder: 5 main and 2 inner classes
Parsing schema file:///home/chris/.pyenv/versions/3.11-dev/envs/xsdata/lib/python3.11/site-packages/xsdata/schemas/xlink.xsd
...
...
Analyzer input: 380 main and 13 inner classes
Analyzer output: 302 main and 4 inner classes
Generating package: init
Generating package: generated.type_type
Generating package: generated.show_type
Generating package: generated.actuate_type
Generating package: generated.simple
Generating package: generated.extended
Generating package: generated.title_elt_type
Generating package: generated.resource_type
Generating package: generated.locator_type
.....
❯ python
Python 3.11.4+ (heads/3.11:ff5dd9d, Jul 30 2023, 17:40:33) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from generated import WfsCapabilitiesType
>>>
I will leave this one open, because I want to check if we can add a validation error to warn users |
Not even mypy can detect the circular imports for the the given schema... |
The cli will still write all generated packages and run the validation at the end, if it fails you will get something like this, to let you know how to proceed
|
Hello,
Models generated from OGC WFS XSD models cannot be used due to circular import:
Is that a bug ?
Best regards, Adam.
The text was updated successfully, but these errors were encountered: