ezmsg-org/ezmsg

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

Closed this issue · 2 comments

(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.

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

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