Skip to content

Commit

Permalink
sync with format.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
zpoint committed Nov 27, 2024
1 parent 20088fb commit e3a55f0
Showing 1 changed file with 55 additions and 32 deletions.
87 changes: 55 additions & 32 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TODO(zpoint): Ensure it is synchronized with format.sh
# Ensure this configuration aligns with format.sh and requirements.txt
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
Expand All @@ -9,49 +9,72 @@ repos:
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 23.12.1
rev: 22.10.0 # Match the version from requirements
hooks:
- id: black
files: sky/skylet/providers/ibm/.*
name: black (IBM specific)
files: "^sky/skylet/providers/ibm/.*" # Match only files in the IBM directory

- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: 5.12.0 # Match the version from requirements
hooks:
# First isort command
- id: isort
exclude: sky/skylet/providers/ibm/.*
args: ["--profile", "google"]
name: isort (general)
args:
- "--sg=build/**" # Matches "${ISORT_YAPF_EXCLUDES[@]}"
- "--sg=sky/skylet/providers/ibm/**"
files: "^(sky|tests|examples|llm|docs)/.*" # Only match these directories
# Second isort command
- id: isort
files: sky/skylet/providers/ibm/.*
args: ["--profile", "black", "-l", "88", "-m", "3"]
stages: [pre-commit]
name: isort (IBM specific)
args:
- "--profile=black"
- "-l=88"
- "-m=3"
files: "^sky/skylet/providers/ibm/.*" # Only match IBM-specific directory

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991 # Match the version from requirements
hooks:
- id: mypy
args:
# from tests/mypy_files.txt
- "sky"
- "--exclude"
- "sky/benchmark|sky/callbacks|sky/skylet/providers/azure|sky/resources.py|sky/backends/monkey_patches"
pass_filenames: false
additional_dependencies:
- types-PyYAML
- types-requests<2.31 # Match the condition in requirements.txt
- types-setuptools
- types-cachetools
- types-pyvmomi

- repo: https://github.com/google/yapf
rev: v0.32.0
rev: v0.32.0 # Match the version from requirements
hooks:
- id: yapf
exclude: (build/.*|sky/skylet/providers/ibm/.*)
additional_dependencies: [toml]
name: yapf
exclude: (build/.*|sky/skylet/providers/ibm/.*) # Matches exclusions from the script
args: ['--recursive', '--parallel'] # Only necessary flags
additional_dependencies: [toml==0.10.2]

- repo: local
- repo: https://github.com/pylint-dev/pylint
rev: v2.14.5 # Match the version from requirements
hooks:
- id: pylint
name: pylint
entry: pylint
language: python
types: [python]
additional_dependencies:
- pylint==2.14.5
- pylint-quotes==0.2.3
args: [
"--load-plugins=pylint_quotes",
"--rcfile=.pylintrc"
]
exclude: ^(build/.*|sky/skylet/providers/ibm/.*|tests/test_smoke\.py)$

- id: mypy
name: mypy
entry: mypy
language: system
types: [python]
require_serial: true
exclude: ^tests/test_smoke\.py$
- pylint-quotes==0.2.3 # Match the version from requirements
name: pylint-only-changed-files
entry: >
bash -c '
MERGEBASE=$(git merge-base origin/main HEAD);
changed_files=$(git diff --name-only --diff-filter=ACM "$MERGEBASE" -- "sky/*.py" "sky/*.pyi");
if [[ -n "$changed_files" ]]; then
echo "$changed_files" | tr "\n" "\0" | xargs -0 pylint --load-plugins=pylint_quotes --rcfile=.pylintrc;
else
echo "Pylint skipped: no files changed in sky/.";
fi'
pass_filenames: false
always_run: true

0 comments on commit e3a55f0

Please sign in to comment.