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

[FIX] get_requirements: add --line_ending argument #98

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ramiadavid
Copy link

I have added the --line_ending argument to avoid differences when running on Windows or Linux, by default Python uses '\n' for Linux and '\r\n' for Windows and this causes problems when running on pre-commit.

Options: cr(\r) | lf(\n) | crlf(\r\n)
Default: lf

@ramiadavid ramiadavid marked this pull request as ready for review November 6, 2022 10:42
@sbidoul
Copy link
Member

sbidoul commented Nov 6, 2022

Thanks for this PR.

Can you elaborate a little bit the problem you are trying to resolve?
Since other tools (such as black, for instance) that modify the code and are run by pre-commit don't typically have that kind of option, I'm not sure we need one here.

@ramiadavid
Copy link
Author

When I run pre-commit on windows it creates the requirements.txt (overwriting existing file) with \r\n but when I push to github and run pre-commit are created with \n and then pre-commit tests fail
In other tools you can specify line endings in .editorconfig but here Python does it automatically depending on the operating system

@sbidoul
Copy link
Member

sbidoul commented Nov 27, 2022

Ok. For the sake of simplicity, I think we can use LF unconditionally. If anyone later needs the configurability, it can be added with proper tests and documentation (taking inspiration from pip-tools --newline option, for instance).

Could you make the change, and also add a newsfragments/98.feature with a short changelog entry?

@ramiadavid
Copy link
Author

Done

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.

2 participants