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
No new line at file end #2328
Comments
Hi, thanks for reporting! However, I can't reproduce this on the playground. I'm not familiar with the docker build though. Do you have the latest version? |
@felix-hilden thank you for the quick response! Steps for reproduce:
Could you please check with such steps? I checked with docker, that builds and installs inside latest black. |
Or use old true python venv module Steps:
|
Given that you are able to reproduce it with an ordinary virtual environment, I think we have something weird going on here. I have the current main (which is equivalent to the latest release) pulled and I created a file like you described: def main():
print(11)
main() It does have the line ending despite what GitHub shows 😅 Both I'm not trying to discredit your finding or say that it's invalid by the way, I hope we can figure out what's going on 😄 |
Please advise, what I'm doing wrong? black_last_line.mp4 |
It looks to me like your file ends with two new‐line characters, and Black is removing the extra one. |
Indeed, could you verify @mironnn by perhaps reading the file in Python or using some other editor? |
Given no one else has reported this bug and we haven't heard anything from the OP in nearly a year, I'm closing this. I'd be happy to reopen this if someone (else) could provide reproduction steps that work. |
@ichard26 you're kidding |
@mironnn I'm not quite sure what you're getting at. It seems to me like Black is functioning as intended. |
I have came across the same thing and I also thought black was removing the new line, but it isn't. |
Add a new line at the end of python file or not to remove it
Currently black removes extra blank line after python code at the end of file.
Tested inside the docker build from the repository.
Desired style
Add a new line at the end of the file.
Flake8 example
https://www.flake8rules.com/rules/W292.html
The text was updated successfully, but these errors were encountered: