Author kj
Recipients gvanrossum, kj, serhiy.storchaka
Date 2021-07-31.16:21:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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)* ","

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:23kjsetrecipients: + kj, gvanrossum, serhiy.storchaka
2021-07-31 16:21:23kjsetmessageid: <>
2021-07-31 16:21:23kjlinkissue44791 messages
2021-07-31 16:21:22kjcreate