diff --git a/snakefmt/parser/syntax.py b/snakefmt/parser/syntax.py index c5e9bd7..55fb879 100644 --- a/snakefmt/parser/syntax.py +++ b/snakefmt/parser/syntax.py @@ -72,6 +72,8 @@ def operator_skip_spacing(prev_token: Token, token: Token) -> bool: return True elif prev_token.type == tokenize.STRING and token.string == ",": return True + elif prev_token.string == "}" and token.string == "{": # issue #220 + return True else: return False diff --git a/tests/test_formatter.py b/tests/test_formatter.py index 2ddc05f..23937a7 100644 --- a/tests/test_formatter.py +++ b/tests/test_formatter.py @@ -861,9 +861,6 @@ def test_f_string_with_double_braces_in_input(self): def test_f_string_with_double_braces_in_python_code(self): """https://github.com/snakemake/snakefmt/issues/215""" - """def get_test_regions(wildcards): - benchmark = config["variant-calls"][wildcards.callset]["benchmark"] - return f"resources/regions/{benchmark}/test-regions.cov-{{cov}}.bed""" snakecode = ( "def get_test_regions(wildcards):\n" f'{TAB * 1}benchmark = config["variant-calls"][wildcards.callset]["benchmark"]\n' # noqa: E501 @@ -872,6 +869,12 @@ def test_f_string_with_double_braces_in_python_code(self): formatter = setup_formatter(snakecode) assert formatter.get_formatted() == snakecode + def test_f_string_spacing_of_consecutive_braces(self): + """https://github.com/snakemake/snakefmt/issues/222""" + snakecode = 'f"{var1}{var2}"\n' + formatter = setup_formatter(snakecode) + assert formatter.get_formatted() == snakecode + class TestReformatting_SMK_BREAK: """