Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid space around pow for None, True and False #8189

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# No spacing
5 ** 5
5.0 ** 5.0
1e5 ** 2e5
True ** True
False ** False
None ** None

# Space
"a" ** "b"
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,12 @@ const fn is_simple_power_operand(expr: &Expr) -> bool {
op: UnaryOp::Not, ..
}) => false,
Expr::Constant(ExprConstant {
value: Constant::Complex { .. } | Constant::Float(_) | Constant::Int(_),
value:
Constant::Complex { .. }
| Constant::Float(_)
| Constant::Int(_)
| Constant::None
| Constant::Bool(_),
..
}) => true,
Expr::Name(_) => true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
source: crates/ruff_python_formatter/tests/fixtures.rs
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary_pow_spacing.py
---
## Input
```py
# No spacing
5 ** 5
5.0 ** 5.0
1e5 ** 2e5
True ** True
False ** False
None ** None

# Space
"a" ** "b"
```

## Output
```py
# No spacing
5**5
5.0**5.0
1e5**2e5
True**True
False**False
None**None

# Space
"a" ** "b"
```



Loading