ezmsg-org / ezmsg

Pure-Python DAG-based high-performance SHM-backed pub-sub and multi-processing pattern
https://ezmsg.readthedocs.io/en/latest/
MIT License
9 stars 4 forks source link

`consumer` return type -- Does `Callable[..., ` work better than `Callable[P, `? #96

Closed cboulay closed 2 months ago

cboulay commented 4 months ago

(very low priority)

I find that when I wrap generator functions with @consumer, the IDE warns me that any arguments to initialize the generator are unexpected.

Screenshot 2024-02-15 at 1 34 27 PM

However, if I change consumer's return type as follows...

def consumer(
    func: Callable[P, Generator[Y, S, None]]
) -> Callable[..., Generator[Y, S, None]]:

then the IDE no longer flags the arguments as unexpected.

I don't know if this has any downstream effects. e.g., I guess this might impact pickling.

griffinmilsap commented 2 months ago

AFAIK typehints don't really affect running code, and I can't see how this could affect pickling... That said, I'm not getting this linting error. With @consumer in its current state, linting works for me. FWIW I'm using VSCode with the Pylance language server.

image
cboulay commented 2 months ago

OK then it's fine as is. Thanks for checking.