How to use the flynt.string_concat.transformer.transform_concat function in flynt

To help you get started, we’ve selected a few flynt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ikamensh / flynt / test / test_str_concat / test_transformer.py View on Github external
def test_existing_fstr_expr():

    txt = """f'blah{thing}' + otherThing + f'blah{thing + 1}'"""
    expected = '''f"blah{thing}{otherThing}blah{thing + 1}"'''

    new, changed = transform_concat(txt)

    assert changed
    assert new == expected
github ikamensh / flynt / test / test_str_concat / test_transformer.py View on Github external
def test_transform_attribute():

    txt = """'blah' + blah.blah"""
    expected = '''f"blah{blah.blah}"'''

    new, changed = transform_concat(txt)

    assert changed
    assert new == expected
github ikamensh / flynt / test / test_str_concat / test_transformer.py View on Github external
def test_transform():

    txt = """a + 'Hello' + b + 'World'"""
    expected = '''f"{a}Hello{b}World"'''

    new, changed = transform_concat(txt)

    assert changed
    assert new == expected
github ikamensh / flynt / test / test_str_concat / test_transformer.py View on Github external
def test_string_in_string_x3():

    txt = """'blah' + blah.blah('more' + vars.foo('other' + b))"""

    new, changed = transform_concat(txt)

    assert changed
    assert "'blah' +" in new
github ikamensh / flynt / test / test_str_concat / test_transformer.py View on Github external
def test_string_in_string():

    txt = """'blah' + blah.blah('more' + vars)"""
    expected = '''f"blah{blah.blah(f'more{vars}')}"'''

    new, changed = transform_concat(txt)

    assert changed
    assert new == expected
github ikamensh / flynt / test / test_str_concat / test_transformer.py View on Github external
def test_transform_complex():

    txt = """'blah' + lst[123].process(x, y, z) + 'Yeah'"""
    expected = '''f"blah{lst[123].process(x, y, z)}Yeah"'''

    new, changed = transform_concat(txt)

    assert changed
    assert new == expected
github ikamensh / flynt / test / test_str_concat / test_transformer.py View on Github external
def test_concats_fstring():

    txt = """print(f'blah{thing}' + 'blah' + otherThing + f"is {x:d}")"""
    expected = """print(f'blah{thing}blah{otherThing}is {x:d}')"""

    new, changed = transform_concat(txt)

    assert changed
    assert new == expected
github ikamensh / flynt / test / test_str_concat / test_transformer.py View on Github external
def test_existing_fstr():

    txt = """f'blah{thing}' + otherThing + 'blah'"""
    expected = '''f"blah{thing}{otherThing}blah"'''

    new, changed = transform_concat(txt)

    assert changed
    assert new == expected
github ikamensh / flynt / test / test_str_concat / test_transformer.py View on Github external
def test_transform_nonatomic():

    txt = """'blah' + (thing - 1)"""
    expected = '''f"blah{thing - 1}"'''

    new, changed = transform_concat(txt)

    assert changed
    assert new == expected
github ikamensh / flynt / test / test_str_concat / test_transformer.py View on Github external
def test_embedded_fstr():

    txt = """print(f"{f'blah{var}' + abc}blah")"""
    expected = """print(f'blah{var}{abc}blah')"""

    new, changed = transform_concat(txt)

    assert changed
    assert new == expected