From f247c39cd876ae0d987c46b48dc2bba97823ca52 Mon Sep 17 00:00:00 2001 From: dylwil3 Date: Fri, 12 Dec 2025 09:13:36 -0600 Subject: [PATCH] doc comments for AttributeState --- .../src/expression/mod.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/ruff_python_formatter/src/expression/mod.rs b/crates/ruff_python_formatter/src/expression/mod.rs index 0349a00e98..6ae482b17f 100644 --- a/crates/ruff_python_formatter/src/expression/mod.rs +++ b/crates/ruff_python_formatter/src/expression/mod.rs @@ -909,8 +909,24 @@ pub enum CallChainLayout { /// element relative to the first call or subscript. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum AttributeState { + /// Stores the number of calls or subscripts on attributes + /// to the left of the current position in a chain. + /// + /// Consecutive calls/subscripts on a single + /// object only count once. For example, if we are at + /// `c` in `a.b()[0]()().c()` then this number would be 1. CallsOrSubscriptsPreceding(u32), + /// Indicates that we are at the first called or + /// subscripted attribute in the chain (and should + /// therefore break). + /// + /// For example, if we are at `b` in `a.b()[0]()().c()` FirstCallOrSubscript, + /// Indicates that we are to the left of the first + /// called or subscripted attribute, and therefore + /// need not break. + /// + /// For example, if we are at `a` in `a.b()[0]()().c()` BeforeFirstCallOrSubscript, } @@ -964,7 +980,7 @@ impl CallChainLayout { comment_ranges: &CommentRanges, source: &str, ) -> Self { - // Count of attribute values which are called or + // Count of attribute _values_ which are called or // subscripted, after the leftmost parenthesized // value. //