Skip to content

Commit

Permalink
Create is_assign method for UnpackValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Glyphack committed Dec 31, 2024
1 parent 7c27a50 commit d499b43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/red_knot_python_semantic/src/types/unpacker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'db> Unpacker<'db> {
.expression()
.node_ref(self.db())
.is_ellipsis_literal_expr();
if matches!(value, UnpackValue::Assign(_)) && is_in_stub_file && value_is_ellipsis_literal {
if value.is_assign() && is_in_stub_file && value_is_ellipsis_literal {
value_ty = Type::Unknown;
} else {
debug_assert!(
Expand Down
5 changes: 5 additions & 0 deletions crates/red_knot_python_semantic/src/unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ impl<'db> UnpackValue<'db> {
matches!(self, UnpackValue::Iterable(_))
}

/// Returns `true` if the value is being assigned to a target.
pub(crate) const fn is_assign(self) -> bool {
matches!(self, UnpackValue::Assign(_))
}

/// Returns the underlying [`Expression`] that is being unpacked.
pub(crate) const fn expression(self) -> Expression<'db> {
match self {
Expand Down

0 comments on commit d499b43

Please sign in to comment.