Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
davidszotten committed Aug 12, 2020
1 parent b59a524 commit bf639cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/black/__init__.py
Expand Up @@ -3287,8 +3287,14 @@ def do_match(self, line: Line) -> TMatchResult:
and LL[next_idx].type == token.RPAR
and not is_empty_rpar(LL[next_idx])
):
# That RPAR should NOT be followed by a '.' symbol.
if is_valid_index(next_idx + 1) and LL[next_idx + 1].type == token.DOT:
# That RPAR should NOT be followed by...
if is_valid_index(next_idx + 1) and (
# a '.' symbol
LL[next_idx + 1].type == token.DOT
or
# a '[' symbol
LL[next_idx + 1].type == token.LSQB
):
continue

return Ok(string_idx)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_black.py
Expand Up @@ -487,6 +487,14 @@ def test_slices(self) -> None:
black.assert_equivalent(source, actual)
black.assert_stable(source, actual, black.FileMode())

@patch("black.dump_to_file", dump_to_stderr)
def test_bracketed_slicing(self) -> None:
source, expected = read_data("bracketed_slicing")
actual = fs(source)
self.assertFormatEqual(expected, actual)
black.assert_equivalent(source, actual)
black.assert_stable(source, actual, black.FileMode())

@patch("black.dump_to_file", dump_to_stderr)
def test_comments(self) -> None:
source, expected = read_data("comments")
Expand Down

0 comments on commit bf639cc

Please sign in to comment.