Conversation
| .is_assignable_to(db, target) => | ||
| { | ||
| true | ||
| } |
There was a problem hiding this comment.
The difference is that we now allow a fall-through to the catch-all "self is subtype of target" branch.
|
|
I have a vague memory of intentionally making the opposite decision here. I think the key question we need to ensure we are answering consistently is, do instances of subclasses of the built-in The potential problem with saying they do not, is that we do need to allow code like this: def f(t: tuple[int, str]): ...
class MyTuple(tuple[int, str]): pass
f(MyTuple((1, "foo")))In other words, if we say they do not, then our |
Ah yes, astral-sh/ty#215 is still unresolved... I have a long reply in my head I've been meaning to write up there for a while :-) maybe I should set an explicit goal for myself to do that on Monday... Anyway, I think the change to the code here is correct even if we disagree on the assertion being made in the mdtest! |
|
Yes, I think the code change is correct, but we should add a TODO comment above the assertions (and maybe also above similar assertions for subtyping, if we have those already?) that we either need to special-case enforcement of Liskov on |
* main: [red-knot] Empty tuple is always-falsy (#17213) Run fuzzer with `--preview` (#17210) Bump 0.11.4 (#17212) [syntax-errors] Allow `yield` in base classes and annotations (#17206) Don't skip visiting non-tuple slice in `typing.Annotated` subscripts (#17201) [red-knot] mypy_primer: do not specify Python version (#17200) [red-knot] Add `Type.definition` method (#17153) Implement `Invalid rule provided` as rule RUF102 with `--fix` (#17138) [red-knot] Add basic on-hover to playground and LSP (#17057) [red-knot] don't remove negations when simplifying constrained typevars (#17189) [minor] Fix extra semicolon for clippy (#17188) [syntax-errors] Invalid syntax in annotations (#17101) [syntax-errors] Duplicate attributes in match class pattern (#17186) [syntax-errors] Fix multiple assignment for class keyword argument (#17184) use astral-sh/cargo-dist instead (#17187) Enable overindented docs lint (#17182)
Summary
Fix assignability of
tuple[()]toAlwaysFalsy.closes #17202
Test Plan
Ran the property tests for a while