Skip to content

Push adapter initialization does not forward annotation arguments correctly #569

@AdamGlustein

Description

@AdamGlustein

Push adapters (potentially all adapters, haven't checked) are normalizing annotation arguments even if they are not within a csp.ts object.

Describe the bug

To Reproduce

from datetime import datetime, timedelta
from typing import Dict, TypeVar

import csp
from csp.impl.pushadapter import PushInputAdapter
from csp.impl.wiring import py_push_adapter_def

T = TypeVar("T")


class _AdapterImpl(PushInputAdapter):
    def __init__(self, ts_typ: T):  # noqa
        print(ts_typ)
        raise

    def start(self, starttime: datetime, endtime: datetime):
        pass

    def stop(self):
        pass

MyPushAdapter = py_push_adapter_def(
    "adapter_def",
    _AdapterImpl,
    csp.ts[T],
    ts_typ=T,
)

@csp.graph
def my_graph() -> csp.ts[Dict[str, int]]:
    data = MyPushAdapter(ts_typ=Dict[str,int])
    return data

csp.run(my_graph, starttime=datetime.utcnow(), endtime=timedelta())

Prints: class <dict> instead of typing.Dict[str, int]

Expected behavior

Should print typing.Dict[str, int]

Error Message

Runtime Environment

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

Additional context

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