Open Strum355 opened 3 months ago
Ah, I ended up just copying the behavior from Pyright here, which emits an error diagnostic if the bare *
parameter isn't annotated, e.g.
def foo(*, x):
# type: (str) -> None
pass
yields
Parameter annotation count mismatch: expected 2 but received 1
while
def foo(*, x):
# type: (None, str) -> None
pass
seems to make Pyright happy.
I'll take a look through the pep 484 doc again and see if it says anything about annotating *
parameters
(Discovered upon using
bazel_env
here: https://github.com/buildbuddy-io/bazel_env.bzl/blob/main/bazel_env.bzl#L339)Given the function
def bazel_env(*, name, tools = {}, toolchains = {}, **kwargs):
with the type comment# type: (string, dict[string, string | Label], dict[string, string | Label]) -> None
, starpls treats the*
as being of typestring
,name
asdict[string, string | Label]
etc.From the Starlark spec on fuction signatures: