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

file-contents-sorter adds an extra blank line if the file to be sorted is empty #935

Closed
paduszyk opened this issue Jul 20, 2023 · 0 comments · Fixed by #944
Closed

file-contents-sorter adds an extra blank line if the file to be sorted is empty #935

paduszyk opened this issue Jul 20, 2023 · 0 comments · Fixed by #944

Comments

@paduszyk
Copy link

I am on v.4.4.0, Python 3.11.4, macOS Ventura 13.4.1.

My .pre-commit-config.yaml:

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: "v4.4.0"
    hooks:
      - id: end-of-file-fixer
      - id: file-contents-sorter
        files: ^requirements\/.+\.in$
        # args: [--unique, --ignore-case]

The files are intentionally empty – I'm in the planning stage, they are just placeholders for requriements1.

To the point: file-contents-sorter adds an extra blank to them, what results in a confict with end-of-file-fixer. I am not sure if that is the expected behavior... Updating args doesn't have any effect.

$ git:(install-and-configure-pre-commit) : pre-commit run --all-files
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing requirements/build.in
Fixing requirements/lint.in
Fixing requirements/test.in

file contents sorter.....................................................Failed
- hook id: file-contents-sorter
- exit code: 1
- files were modified by this hook

Sorting requirements/build.in
Sorting requirements/lint.in
Sorting requirements/test.in

Footnotes

  1. Yes, I know that I can use requirements-txt-fixer particularly for requirements. 😄 I will do. For that issue it doesn't matter.

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

Successfully merging a pull request may close this issue.

2 participants