IMO I think using normal python functions to do these kinds of type transformations should be reconsidered as I think that’s definitely the best option. Yes, it is quite complex to implement, although I am unsure why it would be significantly more complex than the current proposal. And it would, with a bit of care, make the code readable in a way that the current proposal never will be.
IMO:
Complexity for type checking implementers is less important than
Complexity for people writing type expression is less important than
Complexity for people using a typed library.
I agree that this proposal successfully reduces complexity for the last group, but I believe that we can reduce the complexity for the second group significantly by moving some of it into the first group.
We discuss this some in the PEP (PEP 827 – Type Manipulation | peps.python.org), though it is true that much of the focus there is seemingly on the first group. I think that using “normal python functions” for this does not reduce complexity for the second group nearly as much as it might appear:
- They wouldn’t really be normal Python functions. They would be functions in a new sublanguage that includes some of python but not all of it, despite being written as Python functions in Python files, and which programmers would need to understand the boundaries of to use.
- I think in practice most of the complexity in using this will be in the operators being used, not in the syntax, which would be approximately the same in a “normal Python functions” proposal