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

(🎁) Remove redundant parenthesis in subscript operations #3680

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

KotlinIsland
Copy link
Contributor

@KotlinIsland KotlinIsland commented May 5, 2023

Description

Okay, so basically I think this is a based feature because of the confusing nature of the implicit tupleification of getitem.

(Also it will help with KotlinIsland/basedmypy#418)

Checklist - did you ... know ❓

  • [🚀] Add an entry in CHANGES.md if necessary?
  • [🚀] Add / update tests if necessary?
  • [📉] Add new / update outdated documentation?

I'm not familiar with this codebase sorry, all feedback is welcome!

@github-actions
Copy link

github-actions bot commented May 5, 2023

diff-shades results comparing this PR (9e5a1e6) to main (27c05e1). The full diff is available in the logs under the "Generate HTML diff report" step.

╭──────────────────────── Summary ─────────────────────────╮
│ 10 projects & 94 files changed / 578 changes [+286/-292] │
│                                                          │
│ ... out of 2 495 236 lines, 11 738 files & 23 projects   │
╰──────────────────────────────────────────────────────────╯

Differences found.

What is this? | Workflow run | diff-shades documentation

CHANGES.md Outdated
@@ -16,6 +16,7 @@

- Implicitly concatenated strings used as function args are no longer wrapped inside
parentheses (#3640)
- Redundant parenthesis are removed from `__getitem__`/`__setitem__` calls (#3680)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Redundant parenthesis are removed from `__getitem__`/`__setitem__` calls (#3680)
- Redundant parentheses are removed from subscript operations (#3680)

)
or (
is_walrus_assignment(node.children[1])
# This is only supported in py310 and up
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use black.mode.supports_feature here.

x[(1, 2)] = 1
x[1, 2] = 1
x[(1, 2)] = 1
x[(1, 2),] = 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some test cases that use del x[(1)] and similar, just because it's different in the grammar

@KotlinIsland KotlinIsland changed the title (🎁) Remove redundant parenthesis in __getitem__ calls (🎁) Remove redundant parenthesis in subscript operations May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(🎁) Remove redundant parenthesis in getitem/indexing operator
2 participants