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

bpo-38870: Don't start generated output with newlines #19636

Merged
merged 2 commits into from May 3, 2020

Conversation

isidentical
Copy link
Sponsor Member

@isidentical isidentical commented Apr 21, 2020

This is a small nit that can cause too much unnecessary nose when using ast.unparse for comparisons. Examples

 $ python
Python 3.9.0a5+ (heads/master:5565c30f0b, Apr 17 2020, 16:56:39) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> ast.unparse(ast.parse("compile"))
'\ncompile'
>>> ast.unparse(ast.parse("compile")) == "compile"
False
>>> ast.unparse(ast.parse("class compile: pass"))
'\n\nclass compile():\n    pass'

https://bugs.python.org/issue38870

Copy link
Member

@pablogsal pablogsal left a comment

Just a nit: I find newline() a bit misleading if it can actually not produce a newline. Maybe rename to maybe_newline or something like that. Otherwise LGTM

@isidentical
Copy link
Sponsor Member Author

isidentical commented May 3, 2020

@pablogsal okey, I wasn't sure if we wanted to expose that in the method name but changed it to maybe_newline anyways.

@pablogsal pablogsal merged commit 493bf1c into python:master May 3, 2020
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants