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

Change line-ending default to auto #8057

Merged
merged 1 commit into from Oct 19, 2023
Merged

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Oct 19, 2023

Summary

This PR changes the format.line-ending default from lf to auto.

The motivation for defaulting to lf is to ensure all files in a project use the same line ending, regardless of the file author's platform. However, it has the downside that it results in unexpected line-ending changes for existing projects that use a mixture of \n and \r\n and projects that use windows only.
We haven't received much feedback on the lf default, but there has been at least one occurrence where a user was confused about why Ruff changed all lines.
They struggled to understand the changes because many diff viewers hide whitespace changes by default.
We also put them in an uncomfortable position because they were unfamiliar with line endings (the difference between \n and \r\n) and didn't know what option to choose. So they defaulted to auto because it seems like the most clever option that hopefully does the right thing for them.

Breaking Change

While this is a breaking change because it changes the configuration, it doesn't require a new minor version because the formatter is still in alpha (excluded from versioning).

Test Plan

I added a new integration test that ensures the formatter preserves the line ending choice when run without any options.

@MichaReiser
Copy link
Member Author

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@MichaReiser MichaReiser added breaking Breaking API change formatter Related to the formatter labels Oct 19, 2023
@github-actions
Copy link

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍

@MichaReiser MichaReiser merged commit 962472d into main Oct 19, 2023
16 checks passed
@MichaReiser MichaReiser deleted the line-ending-default-to-auto branch October 19, 2023 23:13
@Cjkjvfnby
Copy link
Contributor

Thank you!

I got the problem with this default on my regular project on Windows. Git manages line endings for me: https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings. So changes are committed in UNIX style and code on my machine is in Windows style.

@Cjkjvfnby
Copy link
Contributor

Although auto is a great option. For my projects, I'd prefer to use native. It ensures that all my files are done the same way. All projects I have seen with mixed line endings we more resulted in the absence of the tools for fixing it, it was not something that was required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking API change formatter Related to the formatter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants