Skip to content
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

Properly resolve Union of a standard type and csp.ts type within csp.node #495

Open
AdamGlustein opened this issue Mar 20, 2025 · 1 comment
Assignees
Labels
type: bug Concrete, reproducible bugs

Comments

@AdamGlustein
Copy link
Collaborator

AdamGlustein commented Mar 20, 2025

Describe the bug

It seems that Union[X, csp.ts[Y]] is not resolving as a ts-type during parsing.

To Reproduce

import csp
import typing
from datetime import datetime

@csp.node
def n(x: typing.Union[int, csp.ts[int], typing.Any]) -> csp.ts[int]:
    return abs(x)

@csp.graph
def g() -> csp.ts[int]:
    return n(csp.const(1))

res2 = csp.run(g, starttime=datetime(2020,1,1), endtime=datetime(2022,1,1))
print(res2)

Expected behavior

This code should output:

{0: [(datetime(2020,1,1), 1)]}

What I actually get is:

{0: []}

Error Message

Runtime Environment

0.8.0
3.12.9 | packaged by conda-forge | (main, Feb 14 2025, 08:00:06) [GCC 13.3.0]
linux

Additional context

Pertains to #493

@AdamGlustein AdamGlustein added the type: bug Concrete, reproducible bugs label Mar 20, 2025
@ptomecek
Copy link
Collaborator

Nodes will not be able to handle Union types between ts and non-ts types. Instead, we should raise an exception during node signature parsing to that effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Concrete, reproducible bugs
Projects
None yet
Development

No branches or pull requests

3 participants