mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-06 08:30:42 +00:00
[red-knot] Infer subscript expression types for bytes literals (#13901)
## Summary Infer subscript expression types for bytes literals: ```py b = b"\x00abc\xff" reveal_type(b[0]) # revealed: Literal[b"\x00"] reveal_type(b[1]) # revealed: Literal[b"a"] reveal_type(b[-1]) # revealed: Literal[b"\xff"] reveal_type(b[-2]) # revealed: Literal[b"c"] reveal_type(b[False]) # revealed: Literal[b"\x00"] reveal_type(b[True]) # revealed: Literal[b"a"] ``` part of #13689 (https://github.com/astral-sh/ruff/issues/13689#issuecomment-2404285064) ## Test Plan - New Markdown-based tests (see `mdtest/subscript/bytes.md`) - Added missing test for `string_literal[bool_literal]`
This commit is contained in:
parent
73ee72b665
commit
77ae0ccf0f
7 changed files with 156 additions and 68 deletions
|
@ -21,5 +21,6 @@ mod semantic_model;
|
|||
pub(crate) mod site_packages;
|
||||
mod stdlib;
|
||||
pub mod types;
|
||||
mod util;
|
||||
|
||||
type FxOrderSet<V> = ordermap::set::OrderSet<V, BuildHasherDefault<FxHasher>>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue