@@ -183,7 +183,7 @@ static_assert(is_assignable_to(Meta, type[Unknown]))
183
183
## Tuple types
184
184
185
185
``` py
186
- from knot_extensions import static_assert, is_assignable_to
186
+ from knot_extensions import static_assert, is_assignable_to, AlwaysTruthy, AlwaysFalsy
187
187
from typing import Literal, Any
188
188
189
189
static_assert(is_assignable_to(tuple[()], tuple[()]))
@@ -198,6 +198,14 @@ static_assert(is_assignable_to(tuple[()], tuple))
198
198
static_assert(is_assignable_to(tuple[int , str ], tuple ))
199
199
static_assert(is_assignable_to(tuple[Any], tuple ))
200
200
201
+ # TODO : It is not yet clear if we want the following two assertions to hold.
202
+ # See https://github.com/astral-sh/ruff/issues/15528 for more details. The
203
+ # short version is: We either need to special-case enforcement of the Liskov
204
+ # substitution principle on `__bool__` and `__len__` for tuple subclasses,
205
+ # or we need to negate these assertions.
206
+ static_assert(is_assignable_to(tuple[()], AlwaysFalsy))
207
+ static_assert(is_assignable_to(tuple[int ], AlwaysTruthy))
208
+
201
209
static_assert(not is_assignable_to(tuple[()], tuple[int ]))
202
210
static_assert(not is_assignable_to(tuple[int ], tuple[str ]))
203
211
static_assert(not is_assignable_to(tuple[int ], tuple[int , str ]))
0 commit comments