Skip to content

form/forminfo can include _UnionGenericAlias #52

Open
@github-actions

Description

@github-actions

# TODO: form/forminfo can include _UnionGenericAlias

        super().__init_subclass__()


if sys.version_info >= (3, 10):
    from types import UnionType

    _UnionTypes = (UnionType, OldUnionType)
    _Forms: TypeAlias = type | UnionType | _SpecialForm  # type: ignore[unused-ignore, no-any-expr]
else:
    _UnionTypes = (OldUnionType,)
    _Forms: TypeAlias = Union[type, _SpecialForm]

# TODO: make this work with any "form", not just unions
#  should be (form: TypeForm, forminfo: TypeForm)
# TODO: form/forminfo can include _UnionGenericAlias
def issubform(form: _Forms, forminfo: _Forms) -> bool:
    """EXPERIMENTAL: Warning, this function currently only supports unions and ``Never``.

    Returns ``True`` if ``form`` is a subform (specialform or subclass) of ``forminfo``.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions