Make pre-commit configuration cross-platform compatible using uv (#2971)
authorAlexey ALERT Rubashёff <alexey.rubasheff@gmail.com>
Thu, 15 Jan 2026 08:03:13 +0000 (10:03 +0200)
committerGitHub <noreply@github.com>
Thu, 15 Jan 2026 08:03:13 +0000 (09:03 +0100)
chore: update pre-commit hooks and enforce LF line endings

- Add configuration to enforce LF line endings for all text files.
- Update pre-commit hooks to use `uv run` instead of `scripts/run-in-env.sh` and reorder `gen_requirements_all` to run first.
- Uses LF line endings in gen_requirements_all.

.gitattributes [new file with mode: 0644]
.pre-commit-config.yaml
scripts/gen_requirements_all.py

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..8dc9278
--- /dev/null
@@ -0,0 +1,2 @@
+# Force LF line endings for all text files
+* text=auto eol=lf
index c9d83886c04f0184da02cce10b9fcc6e002ce0b6..3e4b0d4a415e76befaae2cf04390c24daed1c492 100644 (file)
-repos:
-  - repo: local
-    hooks:
-      - id: ruff-check
-        name: 🐶 Ruff Linter
-        language: system
-        types: [python]
-        entry: scripts/run-in-env.sh ruff check --fix
-        require_serial: true
-        stages: [pre-commit, pre-push, manual]
-      - id: ruff-format
-        name: 🐶 Ruff Formatter
-        language: system
-        types: [python]
-        entry: scripts/run-in-env.sh ruff format
-        require_serial: true
-        stages: [pre-commit, pre-push, manual]
-      - id: check-ast
-        name: 🐍 Check Python AST
-        language: system
-        types: [python]
-        entry: scripts/run-in-env.sh check-ast
-      - id: check-case-conflict
-        name: 🔠 Check for case conflicts
-        language: system
-        entry: scripts/run-in-env.sh check-case-conflict
-      - id: check-docstring-first
-        name: ℹ️  Check docstring is first
-        language: system
-        types: [python]
-        entry: scripts/run-in-env.sh check-docstring-first
-      - id: check-executables-have-shebangs
-        name: 🧐 Check that executables have shebangs
-        language: system
-        types: [text, executable]
-        entry: scripts/run-in-env.sh check-executables-have-shebangs
-        stages: [pre-commit, pre-push, manual]
-      - id: check-json
-        name: { Check JSON files
-        language: system
-        types: [json]
-        entry: scripts/run-in-env.sh check-json
-        files: ^(music_assistant/.+/manifest\.json)|(tests/providers/.+/fixtures/.+\.json)$
-      - id: check-merge-conflict
-        name: 💥 Check for merge conflicts
-        language: system
-        types: [text]
-        entry: scripts/run-in-env.sh check-merge-conflict
-      - id: check-symlinks
-        name: 🔗 Check for broken symlinks
-        language: system
-        types: [symlink]
-        entry: scripts/run-in-env.sh check-symlinks
-      - id: check-toml
-        name: ✅ Check TOML files
-        language: system
-        types: [toml]
-        entry: scripts/run-in-env.sh check-toml
-      - id: codespell
-        name: ✅ Check code for common misspellings
-        language: system
-        types: [text]
-        entry: scripts/run-in-env.sh codespell
-      - id: detect-private-key
-        name: 🕵️  Detect Private Keys
-        language: system
-        types: [text]
-        entry: scripts/run-in-env.sh detect-private-key
-      - id: end-of-file-fixer
-        name: ⮐  Fix End of Files
-        language: system
-        types: [text]
-        entry: scripts/run-in-env.sh end-of-file-fixer
-        stages: [pre-commit, pre-push, manual]
-      - id: no-commit-to-branch
-        name: 🛑 Don't commit to stable branch
-        language: system
-        entry: scripts/run-in-env.sh no-commit-to-branch
-        pass_filenames: false
-        always_run: true
-        args:
-          - --branch=stable
-      - id: trailing-whitespace
-        name: ✄  Trim Trailing Whitespace
-        language: system
-        types: [text]
-        entry: scripts/run-in-env.sh trailing-whitespace-fixer
-        stages: [pre-commit, pre-push, manual]
-      - id: mypy
-        name: mypy
-        entry: scripts/run-in-env.sh mypy
-        language: script
-        types: [python]
-        require_serial: true
-        pass_filenames: false
-      - id: gen_requirements_all
-        name: gen_requirements_all
-        entry: scripts/run-in-env.sh python3 -m scripts.gen_requirements_all
-        pass_filenames: false
-        language: script
-        types: [text]
-        files: ^(music_assistant/.+/manifest\.json|pyproject\.toml|\.pre-commit-config\.yaml|scripts/gen_requirements_all\.py)$
+repos:\r
+  - repo: local\r
+    hooks:\r
+      # gen_requirements_all modifies files so it has to be first\r
+      - id: gen_requirements_all\r
+        name: gen_requirements_all\r
+        entry: uv run -m scripts.gen_requirements_all\r
+        pass_filenames: false\r
+        language: system\r
+        types: [text]\r
+        files: ^(music_assistant/.+/manifest\.json|pyproject\.toml|\.pre-commit-config\.yaml|scripts/gen_requirements_all\.py)$\r
+\r
+      - id: ruff-check\r
+        name: 🐶 Ruff Linter\r
+        language: system\r
+        types: [python]\r
+        entry: uv run ruff check --fix\r
+        require_serial: true\r
+        stages: [pre-commit, pre-push, manual]\r
+\r
+      - id: ruff-format\r
+        name: 🐶 Ruff Formatter\r
+        language: system\r
+        types: [python]\r
+        entry: uv run ruff format\r
+        require_serial: true\r
+        stages: [pre-commit, pre-push, manual]\r
+\r
+      - id: check-ast\r
+        name: 🐍 Check Python AST\r
+        language: system\r
+        types: [python]\r
+        entry: uv run check-ast\r
+\r
+      - id: check-case-conflict\r
+        name: 🔠 Check for case conflicts\r
+        language: system\r
+        entry: uv run check-case-conflict\r
+\r
+      - id: check-docstring-first\r
+        name: ℹ️  Check docstring is first\r
+        language: system\r
+        types: [python]\r
+        entry: uv run check-docstring-first\r
+\r
+      - id: check-executables-have-shebangs\r
+        name: 🧐 Check that executables have shebangs\r
+        language: system\r
+        types: [text, executable]\r
+        entry: uv run check-executables-have-shebangs\r
+        stages: [pre-commit, pre-push, manual]\r
+\r
+      - id: check-json\r
+        name: { Check JSON files\r
+        language: system\r
+        types: [json]\r
+        entry: uv run check-json\r
+        files: ^(music_assistant/.+/manifest\.json)|(tests/providers/.+/fixtures/.+\.json)$\r
+\r
+      - id: check-merge-conflict\r
+        name: 💥 Check for merge conflicts\r
+        language: system\r
+        types: [text]\r
+        entry: uv run check-merge-conflict\r
+\r
+      - id: check-symlinks\r
+        name: 🔗 Check for broken symlinks\r
+        language: system\r
+        types: [symlink]\r
+        entry: uv run check-symlinks\r
+\r
+      - id: check-toml\r
+        name: ✅ Check TOML files\r
+        language: system\r
+        types: [toml]\r
+        entry: uv run check-toml\r
+\r
+      - id: codespell\r
+        name: ✅ Check code for common misspellings\r
+        language: system\r
+        types: [text]\r
+        entry: uv run codespell\r
+\r
+      - id: detect-private-key\r
+        name: 🕵️ Detect Private Keys\r
+        language: system\r
+        types: [text]\r
+        entry: uv run detect-private-key\r
+\r
+      - id: end-of-file-fixer\r
+        name: ⮐ Fix End of Files\r
+        language: system\r
+        types: [text]\r
+        entry: uv run end-of-file-fixer\r
+        stages: [pre-commit, pre-push, manual]\r
+\r
+      - id: no-commit-to-branch\r
+        name: 🛑 Don't commit to stable branch\r
+        language: system\r
+        entry: uv run no-commit-to-branch\r
+        pass_filenames: false\r
+        always_run: true\r
+        args:\r
+          - --branch=stable\r
+\r
+      - id: trailing-whitespace\r
+        name: ✄ Trim Trailing Whitespace\r
+        language: system\r
+        types: [text]\r
+        entry: uv run trailing-whitespace-fixer\r
+        stages: [pre-commit, pre-push, manual]\r
+\r
+      - id: mypy\r
+        name: mypy\r
+        entry: uv run mypy\r
+        language: system\r
+        types: [python]\r
+        require_serial: true\r
+        pass_filenames: false\r
index c5b23a22efa29ba3800bc9db242b45ea8dee9e65..ec9c5227e4b7ee00c81890c743605a27596ddbe8 100644 (file)
@@ -80,7 +80,8 @@ def main() -> int:
     for req_key in sorted(final_requirements):
         req_str = final_requirements[req_key]
         content += f"{req_str}\n"
-    Path("requirements_all.txt").write_text(content)
+    # Always use LF line endings for cross-platform compatibility
+    Path("requirements_all.txt").write_text(content, newline="\n")
 
     return 0