Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmojaki committed Dec 19, 2022
1 parent 052205d commit 4f68f9e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fvalues/f.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class FValue:
# Python source code of the expression.
# Doesn't include the format spec or conversion specifier in f-strings,
# e.g. in `{foo()!r:.2f}` it's just the `foo()`.
# In rare cases this may
# In rare cases this may not be the original source code,
# but rather equivalent code produced by `ast.unparse()`.
# This is needed due to Python bugs in slightly older versions
# involving the locations of nodes within f-strings.
source: str

# Original (possibly non-str) value of the expression before formatting.
Expand Down Expand Up @@ -147,6 +150,7 @@ def flatten(self) -> "F":
if isinstance(part, FValue) and isinstance(part.value, F):
parts.extend(part.value.flatten().parts)
elif isinstance(part, F):
# Happens with concatenation when the source node can't be found.
parts.extend(part.flatten().parts)
else:
parts.append(part)
Expand Down

0 comments on commit 4f68f9e

Please sign in to comment.