another bad test for long bodies with their own parens

this case ends up too long at 108 columns:

```py
class C:
    def foo():
        if True:
            transaction_count = self._query_txs_for_range(
                get_count_fn=lambda from_ts, to_ts, _chain_id=chain_id: db_evmtx.count_transactions_in_range(
                    chain_id=_chain_id,
                    from_ts=from_ts,
                    to_ts=to_ts,
                ),
            )
```

instead, it should be formatted like this, fitting within 88 columns:

```py
class C:
    def foo():
        if True:
            transaction_count = self._query_txs_for_range(
                get_count_fn=lambda from_ts, to_ts, _chain_id=chain_id: (
				    db_evmtx.count_transactions_in_range(
                        chain_id=_chain_id,
                        from_ts=from_ts,
                        to_ts=to_ts,
					)
                ),
            )
```

we can fix this by removing the `has_own_parentheses` check in the new lambda
formatting, but this breaks other cases. we might want to preserve this? in this
specific ecosystem case, the project has a `noqa: E501` comment, so this seems
to be what they want anyway, although we don't know that when formatting
This commit is contained in:
Brent Westbrook 2025-12-01 10:41:44 -05:00
parent f634bb5247
commit ad3147703d
No known key found for this signature in database
2 changed files with 50 additions and 1 deletions

View File

@ -350,3 +350,14 @@ class C:
_is_recognized_dtype: Callable[[DtypeObj], bool] = lambda x: lib.is_np_dtype(
x, "M"
) or isinstance(x, DatetimeTZDtype)
class C:
def foo():
if True:
transaction_count = self._query_txs_for_range(
get_count_fn=lambda from_ts, to_ts, _chain_id=chain_id: db_evmtx.count_transactions_in_range(
chain_id=_chain_id,
from_ts=from_ts,
to_ts=to_ts,
),
)

View File

@ -356,6 +356,17 @@ class C:
_is_recognized_dtype: Callable[[DtypeObj], bool] = lambda x: lib.is_np_dtype(
x, "M"
) or isinstance(x, DatetimeTZDtype)
class C:
def foo():
if True:
transaction_count = self._query_txs_for_range(
get_count_fn=lambda from_ts, to_ts, _chain_id=chain_id: db_evmtx.count_transactions_in_range(
chain_id=_chain_id,
from_ts=from_ts,
to_ts=to_ts,
),
)
```
## Output
@ -723,6 +734,20 @@ class C:
_is_recognized_dtype: Callable[[DtypeObj], bool] = lambda x: lib.is_np_dtype(
x, "M"
) or isinstance(x, DatetimeTZDtype)
class C:
def foo():
if True:
transaction_count = self._query_txs_for_range(
get_count_fn=lambda from_ts,
to_ts,
_chain_id=chain_id: db_evmtx.count_transactions_in_range(
chain_id=_chain_id,
from_ts=from_ts,
to_ts=to_ts,
),
)
```
@ -973,7 +998,7 @@ class C:
}
@@ -352,12 +336,12 @@
@@ -352,24 +336,22 @@
def foo():
if True:
if True:
@ -991,4 +1016,17 @@ class C:
+ _is_recognized_dtype: Callable[[DtypeObj], bool] = lambda x: (
+ lib.is_np_dtype(x, "M") or isinstance(x, DatetimeTZDtype)
+ )
class C:
def foo():
if True:
transaction_count = self._query_txs_for_range(
- get_count_fn=lambda from_ts,
- to_ts,
- _chain_id=chain_id: db_evmtx.count_transactions_in_range(
+ get_count_fn=lambda from_ts, to_ts, _chain_id=chain_id: db_evmtx.count_transactions_in_range(
chain_id=_chain_id,
from_ts=from_ts,
to_ts=to_ts,
```