Combining Paramspec Union #1184
hmc-cs-mdrissi
started this conversation in
General
Replies: 1 comment 2 replies
-
No, this isn't allowed. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
When using paramspecs is union present with P.args/P.kwargs intended to be legal or not?
I looked over pep 612, but it does not specify how unions interact with P.args/P.kwargs. Here I'm interpreting union as each argument either matches Sequence[object] or is compatible P.args (original arg type). My primary use case is for similar problems as this prior question. If this is supported then function mentioned there could be hinted as,
Still not fully precise as real intent is closer to ObjectRef[X] where X matches original argument type, but it would get much closer without requiring Map operator.
edit: Pondering this it feels a bit messy semantic. Since removing Paramspec and just doing
would be legal although number of arguments is now a mismatch with number add had. So my guess is unions don't fit together well with P.args and type hinting function like remote remains hard.
Beta Was this translation helpful? Give feedback.
All reactions