8000 Support subcriptable types and new Union Type · Issue #681 · tefra/xsdata · GitHub
[go: up one dir, main page]

Skip to content
Support subcriptable types and new Union Type #681
@tefra

Description

@tefra

The default generator has to remain compatible with all python versions, but someone could use https://github.com/asottile/pyupgrade to upgrade to 3.10 syntax.

Foo | Bar instead of typing.Union[Foo, Bar]
FooBar | None instead of typing.Optional[FooBar]
dict[str, FooBar] instead of typing.Dict[str, FooBar]
list[FooBar] instead of typing.List[FooBar]
tuple[FooBar, ...] instead of typing.Tuple[FooBar, ...]

xsdata should be able to resolve the typing annotations but there are a couple of issues

  • The new UnionType is not supported at all by xsdata
  • The subscriptable types don't evaluate forward references correctly, the issue was fixed in 3.11 but it wasn't backported to 3.10

The first issue is easy to correct but the second I am not so sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0