merely-useful / py-rse

Research Software Engineering with Python course material
http://third-bit.com/py-rse/
Other
246 stars 63 forks source link

EOF newline #556

Closed k8hertweck closed 3 years ago

k8hertweck commented 3 years ago

Nothing in bin/ in the Zipf's Law project directory currently includes a newline at the end of the file, though requirements.txt and files in results/ do. Do we need to include a callout about this, especially since some text editors and git interfaces yell at users about it?

k8hertweck commented 3 years ago

PEP8 standards include an expectation for an empty line: "W292 | no newline at end of file". Clearly this doesn't prevent the code from functioning as expected, though. I know our python code has been run through a linter; is there a reason why we haven't included empty lines?

I'm inclined to add a pop-out to the advanced shell chapter that suggests empty lines at the end of shell scripts, since using cat to print scripts without them makes them look crappy:

bash-3.2$ cat book_summary.sh 
# Get author information from a Project Gutenberg eBook.
# Usage: bash book_summary.sh /path/to/file.txt what_to_look_for
head -n 17 $1 | tail -n 8 | grep $2bash-3.2$ 

I'll need to know how to proceed before I continue developing Amira's repo.

DamienIrving commented 3 years ago

I think we should definitely include a newline at the end of all our bash scripts, python scripts and makefiles. For some reason pycodestyle didn't pick up that problem when I ran it on the python scripts in zipf/bin, but it should have.

A pop-out in the advanced shell chapter would work - for python scripts it might also be worth mentioning it in the "writing readable code" appendix.

k8hertweck commented 3 years ago

Great, I’ll include these items in #554 . Thanks for the confirmation!