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

Keep consistent line endings #201

Merged
merged 1 commit into from
Jul 7, 2022

Conversation

radoering
Copy link
Member

Resolves: #200

With this change, when reading a toml file with consistent line endings, changing the content and writing the content into a file, the result is a file with the same consistent line endings as the input file.

Further, default line endings for Windows when creating a new toml file will be Windows line endings ("\r\n") again.

This change is not perfect, because it only ensures that the written file has consistent line endings. Dumping the changed TomlDocument as string still has inconsistent line endings. However, keeping consistent line endings for TomlDocument seems to require way more effort since hard coded "\n" is used in many places.

@frostming
Copy link
Contributor

Hmm, that does break the integration tests, please have a look? @radoering

@radoering
Copy link
Member Author

@frostming poetry tests were kind of unintentionally expecting inconsistent line endings... They should be forward compatible now. Please re-run the failing tests.

Copy link
Contributor

@frostming frostming left a comment

Choose a reason for hiding this comment

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

LGTM

@frostming frostming merged commit 01e56ea into python-poetry:master Jul 7, 2022
capuanob pushed a commit to capuanob/tomlkit that referenced this pull request Mar 1, 2023
@bmitc
Copy link

bmitc commented Feb 2, 2024

Further, default line endings for Windows when creating a new toml file will be Windows line endings ("\r\n") again.

Is it possible to add a configuration setting for this? I am using Poetry, and it is rather tedious that Poetry automatically generates files using CRLF line endings when I'm on Windows when everything else in my editor creates files with LF line endings, on any operating system. I configure VS Code and Git such that only LF files are created and Git never changes them.

@frostming
Copy link
Contributor

frostming commented Feb 3, 2024

Is it possible to add a configuration setting for this?

You are free not to use the TOMLFile API and read and tomlkit.parse the document yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression: inconsistent line endings
3 participants