Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
randolf-scholz/mypy
#6Labels
bugmypy got something wrongmypy got something wrongtopic-callsFunction calls, *args, **kwargs, defaultsFunction calls, *args, **kwargs, defaultstopic-paramspecPEP 612, ParamSpec, ConcatenatePEP 612, ParamSpec, Concatenate
Description
fromtypingimportCallabledefas_tuple[*Ts](*args: *Ts) ->tuple[*Ts]: returnargsdeftuple_identity[*Ts](t: tuple[*Ts]) ->tuple[*Ts]: returntdeftuple_identity2[T: tuple](t: T) ->T: returntdeftest_paramspec[**P]( dummy: Callable[P, None], # ensure P is bound/, *args: P.args, **kwargs: P.kwargs, ) ->None: reveal_type(args) # N: "P.args`-1" reveal_type( (*args,) ) # N: "builtins.tuple[P.args`-1, ...]"reveal_type( tuple(args) ) # N: "builtins.tuple[builtins.object, ...]"reveal_type(as_tuple(*args)) # N: "builtins.tuple[P.args`-1, ...]"reveal_type(tuple_identity(args)) # N: "builtins.tuple[Never, ...]"# E: [arg-type]reveal_type(tuple_identity2(args)) # N: "P.args`-1" ✅ifisinstance(args, tuple): passelse: reveal_type(args) # false negative [warn-unreachable]Ideally, all the reveal_types should show the same result (or raise errors if considered misuse of ParamSpec1), and the else-branch should trigger an unreachable warning.
Footnotes
For instance,
pyrightsaysas_tuple(*args)is illegal. Code sample in pyright playground↩
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-callsFunction calls, *args, **kwargs, defaultsFunction calls, *args, **kwargs, defaultstopic-paramspecPEP 612, ParamSpec, ConcatenatePEP 612, ParamSpec, Concatenate