Skip to content

A way to relax param-spec -- AnyLike #2317

Description

@oxinabox

What what i would really like is #1506
however mapping types is pretty complex and general.

Consider something like Dask's client.submit
submit[T, **P](self, func: Callable[P, T], *args: P.args, **kwargs: P.kwargs) -> Future[T]
What it actually wants is any type in the outer arguments can be
either the original type Q, in P.args or P.kwargs, or Future[Q].

But specifying that is a bit fiddly.

A less complex thing would be to introduce a special form AnyLike
which can be run as

submit[T, **P](self, func: Callable[P, T], *args: AnyLike[P].args, **kwargs: AnyLike[P].kwargs) -> Future[T]
which would have the effect of allowing the types in
args to be Any but the number must match that in the paramspec P,
and similar the types in kwargs can be Any but the names must till match those in the paramspec P

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: featureDiscussions about new features for Python's type annotations

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions