Remove unnecessary LibCST usage in key-in-dict (#6727)

## Summary

We're using LibCST to ensure that we return the full parenthesized range
of an expression, for display purposes. We can just use
`parenthesized_range` which is more efficient and removes one LibCST
dependency.

## Test Plan

`cargo test`
This commit is contained in:
Charlie Marsh 2023-08-21 10:32:09 -04:00 committed by GitHub
parent f017555d53
commit 2405536d03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 92 additions and 76 deletions

View file

@ -339,7 +339,9 @@ impl FormatRule<Suite, PyFormatContext<'_>> for FormatSuite {
pub(crate) fn contains_only_an_ellipsis(body: &[Stmt], comments: &Comments) -> bool {
match body {
[Stmt::Expr(ast::StmtExpr { value, .. })] => {
let [node] = body else { return false; };
let [node] = body else {
return false;
};
matches!(
value.as_ref(),
Expr::Constant(ast::ExprConstant {