Skip to content

Warn on invalid *args and **kwargs with ParamSpec #13892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix CI
  • Loading branch information
sobolevn committed Oct 14, 2022
commit 7779d27ca5e1844928d8dec32c143ddf11765459
3 changes: 2 additions & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,8 @@ def check_function_signature(self, fdef: FuncItem) -> None:
elif len(sig.arg_types) > len(fdef.arguments):
self.fail("Type signature has too many arguments", fdef, blocker=True)

def check_paramspec_definition(self, func: CallableType) -> None:
def check_paramspec_definition(self, func: Type) -> None:
assert isinstance(func, CallableType)
param_spec_var = next(
(var for var in func.variables if isinstance(var, ParamSpecType)), None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A function could have multiple ParamSpec type variables. This only picks the first one. Maybe it's enough to look at the *args and **kwargs arguments only, and ignore the variables? I.e., if either *args or **kwargs has a ParamSpec type, then we'd require that both of them are defined and they both refer to a ParamSpec (and the same ParamSpec).

)
Expand Down