skip_magic_trailing_comma_in_subscript

This commit is contained in:
Jelle Zijlstra 2022-12-10 08:50:37 -08:00
parent 11b0f1e963
commit 0152d51be2
2 changed files with 10 additions and 14 deletions

View File

@ -275,8 +275,7 @@ def has_magic_trailing_comma(
- it's not a single-element subscript
Additionally, if ensure_removable:
- it's not from square bracket indexing
(specifically, single-element square bracket indexing with
Preview.skip_magic_trailing_comma_in_subscript)
(specifically, single-element square bracket indexing)
"""
if not (
closing.type in CLOSING_BRACKETS
@ -308,18 +307,16 @@ def has_magic_trailing_comma(
comma = self.leaves[-1]
if comma.parent is None:
return False
if Preview.skip_magic_trailing_comma_in_subscript in self.mode:
return (
comma.parent.type != syms.subscriptlist
or closing.opening_bracket is None
or not is_one_sequence_between(
closing.opening_bracket,
closing,
self.leaves,
brackets=(token.LSQB, token.RSQB),
)
return (
comma.parent.type != syms.subscriptlist
or closing.opening_bracket is None
or not is_one_sequence_between(
closing.opening_bracket,
closing,
self.leaves,
brackets=(token.LSQB, token.RSQB),
)
return comma.parent.type == syms.listmaker
)
if self.is_import:
return True

View File

@ -151,7 +151,6 @@ class Preview(Enum):
long_docstring_quotes_on_newline = auto()
string_processing = auto()
skip_magic_trailing_comma_in_subscript = auto()
class Deprecated(UserWarning):