mirror of https://github.com/astral-sh/ruff
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:
parent
f634bb5247
commit
ad3147703d
|
|
@ -350,3 +350,14 @@ class C:
|
||||||
_is_recognized_dtype: Callable[[DtypeObj], bool] = lambda x: lib.is_np_dtype(
|
_is_recognized_dtype: Callable[[DtypeObj], bool] = lambda x: lib.is_np_dtype(
|
||||||
x, "M"
|
x, "M"
|
||||||
) or isinstance(x, DatetimeTZDtype)
|
) 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,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -356,6 +356,17 @@ class C:
|
||||||
_is_recognized_dtype: Callable[[DtypeObj], bool] = lambda x: lib.is_np_dtype(
|
_is_recognized_dtype: Callable[[DtypeObj], bool] = lambda x: lib.is_np_dtype(
|
||||||
x, "M"
|
x, "M"
|
||||||
) or isinstance(x, DatetimeTZDtype)
|
) 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
|
## Output
|
||||||
|
|
@ -723,6 +734,20 @@ class C:
|
||||||
_is_recognized_dtype: Callable[[DtypeObj], bool] = lambda x: lib.is_np_dtype(
|
_is_recognized_dtype: Callable[[DtypeObj], bool] = lambda x: lib.is_np_dtype(
|
||||||
x, "M"
|
x, "M"
|
||||||
) or isinstance(x, DatetimeTZDtype)
|
) 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():
|
def foo():
|
||||||
if True:
|
if True:
|
||||||
if True:
|
if True:
|
||||||
|
|
@ -991,4 +1016,17 @@ class C:
|
||||||
+ _is_recognized_dtype: Callable[[DtypeObj], bool] = lambda x: (
|
+ _is_recognized_dtype: Callable[[DtypeObj], bool] = lambda x: (
|
||||||
+ lib.is_np_dtype(x, "M") or isinstance(x, DatetimeTZDtype)
|
+ 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,
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue