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

Output with --stdout flag contains an additional newline compared to without the flag #250

Closed
magnunm opened this issue Jan 5, 2022 · 1 comment · Fixed by #257
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@magnunm
Copy link
Collaborator

magnunm commented Jan 5, 2022

Compared to the result of modifying the file, the output with --stdout contains an additional newline at the end of the file. As I set up my editor to use the stdout to format the file, this would add a extra newline when I run the formatting.

The cause is the print statements here: __main__.py#L257-L270, as print adds a newline at the end. Have changed it to the way I prefer in my local copy by adding end="" to those print statements. Unless the extra newline is in fact wanted, I can make a PR with that change.

How to reproduce:
In an initialized, empty project, run:

$ echo "print('Some test code')" > test.py
$ cat test.py
print('Some test code')
$ darker --stdout test.py
print("Some test code")

$ darker test.py && cat test.py
print("Some test code")

Environment:
darker: commit c5d0f68
python: 3.10
shell: GNU bash

@akaihola
Copy link
Owner

Thanks @magnunm for the report! I vaguely remember some issue with final newlines when implementing --stdout, but can't of course remember any of the details now. Your example seems to clearly indicate wrong behavior, and a fix should definitely be introduced.

Feel free to make a PR if you have time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

2 participants