csp icon indicating copy to clipboard operation
csp copied to clipboard

Allow None output annotations for graphs/nodes without outputs

Open AdamGlustein opened this issue 1 month ago • 0 comments

Describe the bug

If you annotate a graph or node with an output of None (i.e. it has no output), the graph fails to build.

To Reproduce


import csp
from datetime import datetime

@csp.node
def n(x: csp.ts[int]) -> None:
    print(x)

@csp.graph
def g() -> None:
    n(csp.const(1))

csp.run(g, datetime(2020, 1, 1))

gives:

  File "ex.py", line 5, in <module>
    def n(x: csp.ts[int]) -> None:
    ^^^^^^^^^^
csp.impl.wiring.base_parser.CspParseError: outputs must be ts[] or basket types, got None

If you remove the node annotation and instead do:

import csp
from datetime import datetime

@csp.node
def n(x: csp.ts[int]):
    print(x)

@csp.graph
def g() -> None:
    n(csp.const(1))

csp.run(g, datetime(2020, 1, 1))

you get the analogous error for the graph:

  File "/data01/home/ag11460/user/hfalgotr/ex.py", line 9, in <module>
    def g() -> None:
    ^^^^^^^^^^
csp.impl.wiring.base_parser.CspParseError: outputs must be ts[] or basket types, got None

Expected behavior

we should properly parse a None return type

Error Message

Runtime Environment

0.12.0 3.11.11 (main, Jan 30 2025, 14:30:53) [GCC 13.3.0] linux

Additional context

AdamGlustein avatar Nov 17 '25 15:11 AdamGlustein