Skip to content

Commit 97776ee

Browse files
committed
Fix yapf nested fixup regex for edge cases.
1 parent 4b69336 commit 97776ee

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

formate/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def isort_hook(
172172

173173

174174
# e.g. " )⸴ )" or " )))), )"
175-
yapf_nested_fixup_pattern = re.compile(r"([ \t])([)}\]]?)([)}\]], )([)}\]])")
175+
yapf_nested_fixup_pattern = re.compile(r"(\n[ \t]*)([)}\]]*)([)}\]], )([)}\]])")
176176

177177

178178
@wants_global_config

tests/test_yapf_nested_fixups.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ def foo():
3737
def test_tuple():
3838
src = 'top_tmp["normalized"] = top_tmp.apply(normalize, args=(max(top_tmp["intensity"]), ), axis=1)\n'
3939
assert yapf_hook(src, yapf_style=PathPlus(__file__).parent.parent.joinpath(".style.yapf").as_posix()) == src
40+
41+
src = """[
42+
((("bob", )⸴ ), {"use_repr": True, "oxford": True}, "'bob'"),
43+
]
44+
""".replace('⸴', ',')
45+
46+
assert yapf_hook(src, yapf_style=PathPlus(__file__).parent.parent.joinpath(".style.yapf").as_posix()) == src

0 commit comments

Comments
 (0)