-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[red-knot] Empty tuple is always-falsy #17213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| .is_assignable_to(db, target) => | ||
| { | ||
| true | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: 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