[red-knot] Don't infer Todo for quite so many tuple type expressions#17116
[red-knot] Don't infer Todo for quite so many tuple type expressions#17116AlexWaygood merged 1 commit intomainfrom
Conversation
|
|
link to the primer hit: https://github.com/psf/black/blob/2c135edf3732a8efcc89450446fcaa7589e2a1c8/src/blib2to3/pgen2/pgen.py#L164-L187 I think it's probably a false positive, but a single false positive is probably worth it here IMO. This gives us better understanding for a lot of |
dcreager
left a comment
There was a problem hiding this comment.
I think it's probably a false positive, but a single false positive is probably worth it here IMO. This gives us better understanding for a lot of
tupleannotations that we were giving up on parsing before.
There's an assert at the end of that function that should narrow away the None from the second element of the return tuple. If it's quick to figure out why that's happening, I think it would be worth tackling here. But if it's unrelated to the tuple change (i.e. do we also not narrow None | Unknown to Unknown correctly on its own?) then I agree that the one false positive is worth it here.
|
Ah, we don't do type narrowing for |
* main: [red-knot] Add property tests for callable types (#17006) [red-knot] Disjointness for callable types (#17094) [red-knot] Flatten `Type::Callable` into four `Type` variants (#17126) mdtest.py: do a full mdtest run immediately when the script is executed (#17128) [red-knot] Fix callable subtyping for standard parameters (#17125) [red-knot] Fix more `redundant-cast` false positives (#17119) Sync vendored typeshed stubs (#17106) [red-knot] support Any as a class in typeshed (#17107) Visit `Identifier` node as part of the `SourceOrderVisitor` (#17110) [red-knot] Don't infer Todo for quite so many tuple type expressions (#17116) CI: Run pre-commit on depot machine (#17120) Error instead of `panic!` when running Ruff from a deleted directory (#16903) (#17054) Control flow graph: setup (#17064) [red-knot] Playground improvements (#17109) [red-knot] IDE crate (#17045) Update dependency vite to v6.2.4 (#17104) [red-knot] Add redundant-cast error (#17100) [red-knot] Narrowing on `in tuple[...]` and `in str` (#17059)
Summary
I noticed we were inferring
Todoas the declared type for annotations such asx: tuple[list[int], list[int]]. This PR reworks our annotation parsing so that we instead infertuple[Todo, Todo]for this annotation, which is quite a bit more precise.Test Plan
Existing mdtest updated.