-
-
Notifications
You must be signed in to change notification settings - Fork 628
Description
What's the problem this feature will solve?
I'm trying to use the pip-compile hook with my existing pre-commit configuration but one of the hooks I have is a mixed line ending auto-fixer (which I use to ensure all files in the repository use LF for line endings):
repos:
- repo: https://github.com/jazzband/pip-tools
rev: 6.2.0
hooks:
- id: pip-compile
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: mixed-line-ending
args:
- "--fix=lf"
This configuration causes issues whenever I try to touch a requirements file.
Describe the solution you'd like
A way to set the line endings used for the generated requirements.txt
file. The alternative would be for pip-compile to always use \n
but then I'm guessing someone else might complain about it in the future like I'm doing now :)
Alternative Solutions
I can work around this issue by excluding requirement files from the check but this doesn't really solve it as I still end up with requirements files ending with CRLF, it just allows me to continue to use both hooks.
Another solution would be a way for --dry-run
to return non-zero exit code when the file would have any dependencies changed (like what #882 and #1215 suggest) but this doesn't fully solve it either as then you lose the benefit of pip-compile auto-fixing the issue during pre-commit run.
Additional context
I'm using on Windows - os.linesep
is equal to "\r\n"
there