ruff
ruff copied to clipboard
New rule proposal: unnecessary-newline-at-start-of-file
Hi,
I think it could be interesting for ruff to also check for unnecessary newlines at the start of files, a parallel (sort of) to to W292 https://docs.astral.sh/ruff/rules/missing-newline-at-end-of-file/ The idea being, ruff would prevent a file to start with a new line. Currently, ruff is perfectly fine with it.
For example, this works even with all rules selected:
from marshaling import AppSettings
class Settings(AppSettings):
CI_VERSION: str
ENVIRONMENT_NAME: str
SYSTEM_JWT_KEY: str
settings = Settings()
Thanks for the suggestion. Have you considered using ruff format
? It removes the line automatically for you (and inserts the trailing new line)
So, I recon it's bordeline, but also use ruff to check on files types (like behave files) that don't quite work ruff format unfortunately
I'm sorry but I don't follow what you're trying to say here. Can you expand on what do you mean by "don't quite work ruff format"? Are you using any other filetypes which contains Python source code?
I'm going to close this for now as we're trying to be very conservative in adding new formatting-only lint rules now that we have ruff format
, since maintaining compatibility between ruff format
and style rules is tricky.