Return ParamSpec if callable can be called with one. A Callable accepting ParamSpec P args (*args, **kwargs) must have the two final parameters like this: *args: P.args, **kwargs: P.kwargs.
(self)
| 2421 | return a |
| 2422 | |
| 2423 | def param_spec(self) -> ParamSpecType | None: |
| 2424 | """Return ParamSpec if callable can be called with one. |
| 2425 | |
| 2426 | A Callable accepting ParamSpec P args (*args, **kwargs) must have the |
| 2427 | two final parameters like this: *args: P.args, **kwargs: P.kwargs. |
| 2428 | """ |
| 2429 | if len(self.arg_types) < 2: |
| 2430 | return None |
| 2431 | if self.arg_kinds[-2] != ARG_STAR or self.arg_kinds[-1] != ARG_STAR2: |
| 2432 | return None |
| 2433 | arg_type = self.arg_types[-2] |
| 2434 | if not isinstance(arg_type, ParamSpecType): |
| 2435 | return None |
| 2436 | |
| 2437 | # Prepend prefix for def f(prefix..., *args: P.args, **kwargs: P.kwargs) -> ... |
| 2438 | # TODO: confirm that all arg kinds are positional |
| 2439 | prefix = Parameters(self.arg_types[:-2], self.arg_kinds[:-2], self.arg_names[:-2]) |
| 2440 | return arg_type.copy_modified(flavor=ParamSpecFlavor.BARE, prefix=prefix) |
| 2441 | |
| 2442 | def normalize_trivial_unpack(self) -> None: |
| 2443 | # Normalize trivial unpack in var args as *args: *tuple[X, ...] -> *args: X in place. |
no test coverage detected