-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add f-strings to label visitor #142
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚢
pyt/helper_visitors/label_visitor.py
Outdated
def visit_FormattedValue(self, node): | ||
self.result += '{' | ||
self.visit(node.value) | ||
self.result += { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe add a comment for the formatting
self.result += {
-1: '', # no formatting
97: '!a', # ascii formatting
114: '!r', # repr formatting
115: '!s', # string formatting
}[node.conversion]
pyt/helper_visitors/label_visitor.py
Outdated
self.result += "'" | ||
|
||
def visit_FormattedValue(self, node): | ||
self.result += '{' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe add abstract grammar docstrings, I have started to do this recently.
e.g.
"""
JoinedStr(expr* values)
"""
"""
FormattedValue(expr value, int? conversion, expr? format_spec)
"""
Node types FormattedValue and JoinedStr were added in python 3.6.
Comments added as requested. |
Node types
FormattedValue
andJoinedStr
were added in python 3.6.