Skip to content

Handle unions via | with None properly #475

@NeejWeej

Description

@NeejWeej

Describe the bug
When I try to type annotate a csp graph with "int | None" I get a weird failure

To Reproduce

import csp
@csp.graph
def foo(handle: int | None) -> csp.ts[int]:
    return csp.null_ts(int)
foo(5)

Expected behavior
To work the same way Union does. This seems to work without pydantic type checking

Error Message
TypeError: Could not create pydantic model for inputs of foo.
can only concatenate str (not "NoneType") to str

Runtime Environment
sys.version = '3.11.11 (main, Dec 9 2024, 15:32:27) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)]' csp.version = '0.0.11'

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugConcrete, reproducible bugs

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions