Skip to content
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

Minor update to the PEP #17

Merged
merged 3 commits into from
Oct 16, 2024
Merged

Conversation

lysnikolaou
Copy link
Collaborator

I did a first pass and I have some comments (I still need to do another two three passes for a full-on review):

  • I'm not sure about the types module. It seems that it mostly provides types that are the result of calling type on some objects. It would be the first exported symbol that does not with the suffix Type AFAIU.
  • We should add to the specification of the format_spec that in case there's interpolations, they're eagerly evaluated.
  • I'm not sure about the comment that the debug = symbol behaves differently to f-strings. F-strings actually behave the exact same way. If someone ast.parses an f-string, they'll get an AST tree very similar to our Template.args.

@davepeck
Copy link
Owner

davepeck commented Oct 16, 2024

We should add to the specification of the format_spec that in case there's interpolations, they're eagerly evaluated.

@lysnikolaou Good catch. Just added a change for this:

Format specifications in f-strings can themselves contain interpolations. This
is permitted in template strings as well; format_spec is set to the eagerly
evaluated result:

value = 42
precision = 2
template = t"Value: {value:.{precision}f}"
assert template.args[1].format_spec == ".2f"

@davepeck davepeck merged commit 3d5d3f1 into pep750-post-sprint-update Oct 16, 2024
@lysnikolaou lysnikolaou deleted the lysnikolaou-patch-1 branch October 17, 2024 09:03
davepeck added a commit that referenced this pull request Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants