DiamondLightSource / python-copier-template

Replacing Diamond Light Source's python3-pip-skeleton using Copier
Apache License 2.0
4 stars 2 forks source link

Add newlines at ends of files #141

Closed GDYendell closed 2 months ago

GDYendell commented 3 months ago
coretl commented 3 months ago

The blank lines were removed because of the default VSCode formatting setting, I wonder if this still happens in a fresh profile?

joeshannon commented 3 months ago

I've just opened this branch in a "vanilla" vscode (with no extensions).

The only files it formats by default are json and html. Both of these did remove the new line at end of file.

This is a bit of a pain as the unix (and git) convention is to have a new line at the end of file so I'm not really sure what it best to do.

I guess if every formatter could be configured differently it might be an issue

This issue https://github.com/microsoft/vscode/issues/176246 suggests that the json formatter will respect files.insertFinalNewline - I wonder if all formatters do. If so that could be added to the workspace settings.

There is also end-of-file-fixer in pre-commit that could be added.

joeshannon commented 3 months ago

Just to note that after running end-of-file-fixer on the HEAD of this PR there are actually quite a few other files in the project with no new line at EOF.

coretl commented 3 months ago

@joeshannon if you put files.insertFinalNewline in .vscode/setting.json does it respect it?

joeshannon commented 3 months ago

@joeshannon if you put files.insertFinalNewline in .vscode/setting.json does it respect it?

Yes it does

coretl commented 3 months ago

Ok, so happy to accept this PR if we add that line in. Could also add the end-of-file-fixer while we're at it to make sure all files abide by this

joeshannon commented 3 months ago

@joeshannon if you put files.insertFinalNewline in .vscode/setting.json does it respect it?

Yes it does

Just to follow up: for "Format Document" it did take affect for the html formatting but didn't seem to for json, however it did change the behaviour to add the new line when saving the json file.

GDYendell commented 3 months ago

Thanks @joeshannon that looks good!

joeshannon commented 2 months ago

I'm happy with it.

coretl commented 2 months ago

Hmm, we now get a failure: https://github.com/DiamondLightSource/python-copier-template-example/actions/runs/9099023019/job/25010615685

Please can someone put in a PR to delete the extra lines at the end of README.jinja and Dockerfile.jinja?

coretl commented 2 months ago

Actually, I'll do this

coretl commented 2 months ago

https://github.com/DiamondLightSource/python-copier-template/pull/161