Wrap lonesome f-strings in print().
> python3 -m pip install f-codec# -*- coding: f -*-
def dictionary(inst, depth=0):
ಠ_ಠ = ' ' * depth
f''' {{
'''
for name, val in inst.items():
if isinstance(val, dict):
f'''
{name} =
''' > ಠ_ಠ
dictionary(val, depth + 1)
else:
f'''
{name} = {val},
''' > ಠ_ಠ
f'''
}}
''' > ಠ_ಠ
decl = {
'a': 1,
'b': 2,
'c': { 'a': 3, 'b': 4 },
'd': { 'a': 5, 'b': { 'a': 6, 'b': 7 }, 'c': 8 },
'e': 9
}
f'''
decl =
'''
dictionary(decl)> python3 test.py
decl = {
a = 1,
b = 2,
c = {
a = 3,
b = 4,
}
d = {
a = 5,
b = {
a = 6,
b = 7,
}
c = 8,
}
e = 9,
}> python3 -m unittest test_fcodec -v # run the regression suite
> uv build # build sdist and wheel into dist/The test suite compares decoding against golden files in tests/golden/,
which lock in the exact transformation of known-good sources.
- true streaming support for
IncrementalDecoder(currently it buffers the whole input and decodes at once) - skip f-string if the previous line ends with "" and it isn't a comment
- skip f-string inside another string
- support for
''' > indenton a single-line f-string (only whitespace or a comment may follow the closing quotes) - support for triple-quoted strings inside an
''' > indentexpression - preserve CRLF line endings (currently normalized to LF)