Skip to content

Commit 6d5ccca

Browse files
committed
Add a note about Unpack
1 parent 7c4da6f commit 6d5ccca

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

tests/test_fastapilike_1.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,34 @@ class _Default:
7272
*[x for x in Iter[Members[T]]],
7373
]
7474

75+
"""TODO:
76+
77+
We would really like to instead write:
78+
79+
type AddInit[T] = NewProtocol[
80+
InitFnType[T],
81+
*Members[T]],
82+
]
83+
84+
but we struggle here because typing wants to unpack the Members tuple
85+
itself. I'm not sure if there is a nice way to resolve this. We
86+
*could* make our consumers (NewProtocol etc) be more flexible about
87+
these things but I don't think that is right.
88+
89+
The frustrating thing is that it doesn't do much with the unpacked
90+
version, just some checks!
91+
92+
We could fix typing to allow it, and probably provide a hack around it
93+
in the mean time.
94+
95+
Lurr! Writing *this* gets past the typing checks (though we don't
96+
support it yet):
97+
98+
type AddInit[T] = NewProtocol[
99+
InitFnType[T],
100+
*tuple[*Members[T]],
101+
]
102+
"""
75103

76104
type AllOptional[T] = NewProtocol[
77105
*[

0 commit comments

Comments
 (0)