Formatter: different than black when wrapping parentheses for `assert`
- Dominant language
- Rust
- Stars
- 49.6k
- Forks
- 2.4k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 435
Description
The ruff version is v0.1.3.
Original code:
```py
class SomeClass:
def some_method(necessary_key, kwargs):
assert set(necessary_key).issubset(set(kwargs)), "Must give neccessary key: %s" % ", ".join(necessary_key)
```
Black:
```py
class SomeClass:
def some_method(necessary_key, kwargs):
assert set(necessary_key).issubset(
set(kwargs)
), "Must give neccessary key: %s" % ", ".join(necessary_key)
```
ruff:
```py
class SomeClass:
def some_method(necessary_key, kwargs):
assert set(necessary_key).issubset(set(kwargs)), (
"Must give neccessary key: %s" % ", ".join(necessary_key)
)
```
See https://play.ruff.rs/f16cda56-ec7f-4b88-9dc9-1ba2dd18b39b
Contributor guide
Research direction
Reproduce the assert example from the issue with Ruff v0.1.3 and compare its output with Black's output. Start from Ruff's formatter behavior for wrapped assert expressions; done means Ruff uses the expected parenthesis wrapping shown in the Black example and the behavior is covered against regression.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100