Skip to content

Commit

Permalink
Add pre-commit hook
Browse files Browse the repository at this point in the history
First pass at adding a pre-commit hook to enforce
formatting and linting standards.

This adds the pre-commit command to run on a
limited set of directories. Subsequent changes
will remove excluded folders and run formatting on
them as well.

The command will use the standard pre-commit hooks
for yaml, whitespace, and end of line linting.

It will also use `ruff` configured identically to
the Python SDK repositories.

The intention is to start enforcing formatting and
linting standards on edited code. Running the
pre-commit hook manually will make numerous
changes that should be broken into multiple
phases.
  • Loading branch information
kdaily committed Dec 6, 2024
1 parent bf05341 commit 85393a5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
exclude: "\
^(\
.changes|\
.github|\
awscli/examples|\
awscli/topics|\
awscli/botocore|\
awscli/s3transfer|\
awscli/doc|\
exe/assets|\
tests/functional/cloudformation/deploy_templates/booleans/input.yml|\
tests/functional/cloudformation/deploy_templates/nested-tag/input.yml|\
tests/|\
CHANGELOG.rst|\
configure\
)"
repos:
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.8
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
25 changes: 25 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,28 @@ markers = [

[tool.black]
line-length = 80

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F", "I", "UP"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
# Like Black, use double quotes for strings, spaces for indents
# and trailing commas.
quote-style = "preserve"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

docstring-code-format = false
docstring-code-line-length = "dynamic"

0 comments on commit 85393a5

Please sign in to comment.