Message398645
Should Concatenate support substitution to begin with? PEP 612 doesn't say anything, and I am fairly certain it's a special typing form, not a generic. So I don't really understand what it means to substitute Concatenate.
Then again, Callable with a nested Concatenate can be substituted, and we currently implement that by using Concatenate's substitution behavior as proxy. But again, the meaning isn't clear to me.
I also noticed this strange part in PEP 612 about user-defined generic classes:
"`Generic[P]` makes a class generic on `parameters_expressions` (when P is a ParamSpec)":
...
class X(Generic[T, P]):
f: Callable[P, int]
x: T
def f(x: X[int, Concatenate[int, P_2]]) -> str: ... # Accepted (KJ: What?)
...
The grammar for `parameters_expression` is:
parameters_expression ::=
| "..."
| "[" [ type_expression ("," type_expression)* ] "]"
| parameter_specification_variable
| concatenate "["
type_expression ("," type_expression)* ","
parameter_specification_variable
"]"
I'm very confused. Does this mean Concatenate is valid when substituting user generics? Maybe I should ask the PEP authors?
My general sense when I implemented the PEP was that it was intended primarily for static type checking only. IMO, runtime correctness wasn't its concern. |
|
Date |
User |
Action |
Args |
2021-07-31 16:21:23 | kj | set | recipients:
+ kj, gvanrossum, serhiy.storchaka |
2021-07-31 16:21:23 | kj | set | messageid: <1627748483.68.0.529479491503.issue44791@roundup.psfhosted.org> |
2021-07-31 16:21:23 | kj | link | issue44791 messages |
2021-07-31 16:21:22 | kj | create | |
|