Skip to content

Commit 4c0f051

Browse files
MatthewMckee4carljm
authored andcommitted
Fix correction and add tests for LiteralString
1 parent 5960e70 commit 4c0f051

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

crates/ty_python_semantic/resources/mdtest/type_properties/is_assignable_to.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ static_assert(is_assignable_to(Literal["foo"], Sequence[str]))
107107
static_assert(is_assignable_to(Literal["foo"], Sequence[Any]))
108108

109109
static_assert(is_assignable_to(LiteralString, str))
110+
static_assert(is_assignable_to(LiteralString, Sequence))
111+
static_assert(is_assignable_to(LiteralString, Sequence[str]))
112+
static_assert(is_assignable_to(LiteralString, Sequence[Any]))
110113

111114
static_assert(not is_assignable_to(Literal["foo"], Literal["bar"]))
112115
static_assert(not is_assignable_to(str, Literal["foo"]))

crates/ty_python_semantic/src/types.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,8 +1655,9 @@ impl<'db> Type<'db> {
16551655
}
16561656
}
16571657

1658-
_ if self.literal_fallback_instance(db))
1659-
.is_some_and(|instance| instance.is_assignable_to(db, target) =>
1658+
_ if self
1659+
.literal_fallback_instance(db)
1660+
.is_some_and(|instance| instance.is_assignable_to(db, target)) =>
16601661
{
16611662
true
16621663
}

0 commit comments

Comments
 (0)