Skip to content

Commit

Permalink
ci(pre-commit): update pre-commit config to latest Espressif standard
Browse files Browse the repository at this point in the history
  • Loading branch information
tomassebestik committed Sep 6, 2024
1 parent 3940cd5 commit 03bf74f
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 52 deletions.
71 changes: 51 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,62 +1,93 @@
# Run `pre-commit autoupdate` to update to the latest pre-commit hooks version.
# When changing the version of tools that are also installed as development dependencies (e.g., black, mypy, ruff),
# please ensure the same versions are pinned in this file as in `pyproject.toml`.
---
minimum_pre_commit_version: 3.3.0 # Specifies the minimum version of pre-commit required for this configuration
default_install_hook_types: [pre-commit, commit-msg] # Default hook types to install if not specified in individual hooks
default_stages: [pre-commit]

repos:
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace # Removes trailing whitespaces from lines
- id: end-of-file-fixer # Ensures files end with a newline
- id: check-executables-have-shebangs # Checks executables have a proper shebang
- id: check-shebang-scripts-are-executable # Checks that scripts with shebangs are executable.
- id: check-case-conflict # Check conflict on a case-insensitive filesystem (MacOS HFS+/Windows FAT).
- id: mixed-line-ending # Detects mixed line endings (CRLF/LF)
args: ['-f=lf'] # Forces files to use LF line endings
- id: double-quote-string-fixer # Converts single quotes to double quotes in strings
args: ["-f=lf"] # Forces files to use LF line endings

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.6.4
hooks:
- id: ruff # Runs ruff linter (replaces flake8)
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/asottile/reorder_python_imports
rev: v3.12.0
hooks:
- id: reorder-python-imports # Reorders Python imports to a standard format (replaces isort)

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.11.2
hooks:
- id: mypy # Runs mypy for Python type checking
additional_dependencies: ['types-all']

- repo: https://github.com/espressif/conventional-precommit-linter
rev: v1.6.0
rev: v1.10.0
hooks:
- id: conventional-precommit-linter # Lints commit messages for conventional format
stages: [commit-msg]

- repo: https://github.com/psf/black
rev: '24.1.1'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.4
hooks:
- id: black # Formats Python code using black
- id: ruff # Linter
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format # Formatter (replaces Black)

- repo: https://github.com/pylint-dev/pylint
rev: v3.0.3
rev: v3.2.7
hooks:
- id: pylint # Runs pylint on Python code

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell # Code spell checker
args: ["--write-changes"]
additional_dependencies: [tomli]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
args: [--number] # Keep numbering for ordered lists
additional_dependencies:
- mdformat-gfm # Support for GitHub Flavored Markdown (GFM), including tables, task lists, strikethroughs, and autolinks.
- mdformat-ruff # Formats Python code blocks in Markdown files according to the `ruff` linter's style.
- mdformat-simple-breaks # Ensures that single line breaks in Markdown are converted to `<br>` t

- repo: https://github.com/AleksaC/hadolint-py
rev: v2.12.1b3
hooks:
- id: hadolint
args:
- --ignore=DL3025 # Allow any registry in FROM
- --ignore=DL3018 # No version pin in apt-get (Debian)
- --ignore=DL3008 # No version pin in apk add (Alpine)
- --ignore=DL3013 # No version pin in pip install

- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args:
- --base64-limit=4 # Level of entropy for base64 type strings
- --hex-limit=3 # Level of entropy for hex strings

- repo: https://github.com/lyz-code/yamlfix/
rev: 1.17.0
hooks:
- id: yamlfix

# Local hooks
- repo: local
Expand Down
67 changes: 35 additions & 32 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,37 @@
dependencies = ["PyGithub==2.2.0", "jira==3.6.0"]

[project.optional-dependencies]
dev = [
"commitizen",
"pip-tools~=7.3",
"pre-commit>=3.3",
"pytest",
"pytest-cov",
]
dev = ["commitizen", "pip-tools~=7.3", "pre-commit>=3.3", "pytest", "pytest-cov"]

[tool.setuptools_scm]
write_to = "sync_jira_actions/version.py"

[tool.black]
line-length = 120 # The maximum line length for Python code formatting
skip-string-normalization = true # Avoids converting single quotes to double quotes in strings (pre-commit hook enforces single quotes in Python code)

[tool.ruff]
line-length = 120 # Specifies the maximum line length for ruff checks
select = ['E', 'F', 'W'] # Types of issues ruff should check for
target-version = "py311" # Specifies the target Python version for ruff checks
exclude = ["tests/.*"] # Exclude specific paths
line-length = 120 # Specifies the maximum line length for ruff checks
lint.select = [
"B", # Bugbear: Enforces additional linting rules aimed at catching common bugs and design issues.
"E", # pycodestyle Error: Enforces PEP 8 error checks related to formatting and code style.
"F", # Pyflakes: Detects common errors like unused imports, undefined variables, and more.
"I", # Isort: Ensures that imports are sorted and grouped correctly.
"S", # Security: Includes security-related linting rules from the Bandit plugin.
"W", # pycodestyle Warning: Enforces PEP 8 warnings, such as trailing whitespace or missing newlines.
] # Selects specific linting rules from various sources
target-version = "py311" # Specifies the target Python version for ruff checks

[tool.ruff.format] # See formatter config options at https://docs.astral.sh/ruff/formatter
quote-style = "single"

[tool.ruff.lint.isort]
force-single-line = true # Forces all imports to be placed on individual lines, improving readability and reducing merge conflicts.
lines-between-types = 1 # Ensures there is one blank line between different types of imports (e.g., standard library, third-party, local imports).

[tool.mypy]
disallow_incomplete_defs = false # Disallows defining functions with incomplete type annotations
disallow_untyped_defs = false # Disallows defining functions without type annotations or with incomplete type annotations
exclude = '^venv/' # Paths to ignore during type checking
ignore_missing_imports = true # Suppress error messages about imports that cannot be resolved
python_version = "3.11" # Specifies the Python version used to parse and check the target program
python_version = "3.11" # Specifies the Python version used to parse and check the target program
warn_no_return = true # Shows errors for missing return statements on some execution paths
warn_return_any = true # Shows a warning when returning a value with type Any from a function declared with a non- Any return type

Expand Down Expand Up @@ -70,7 +75,6 @@
[tool.pylint.'FORMAT']
max-line-length = 120 # Specifies the maximum line length for pylint checks


[tool.pytest.ini_options]
addopts = "-s --log-cli-level DEBUG --cov=. --cov-report=term"
python_classes = ["Test*"]
Expand All @@ -90,22 +94,13 @@
version_provider = "scm"

[tool.commitizen.customize]
bump_map = { "change" = "MINOR", "feat" = "MINOR", "fix" = "PATCH", "refactor" = "PATCH", "remove" = "PATCH", "revert" = "PATCH" }
bump_pattern = "^(change|feat|fix|refactor|remove|revert)"
change_type_order = [
"change",
"ci",
"docs",
"feat",
"fix",
"refactor",
"remove",
"revert",
]
example = "change: this is a custom change type"
message_template = "{% if scope %}{{change_type}}({{scope}}): {{message}}{% else %}{{change_type}}: {{message}}{% endif %}{% if body %}\n\n{{body}}{% endif %}{% if is_breaking_change %}\n\nBREAKING CHANGE{% endif %}{% if footer %}\n\n{{footer}}{% endif %}"
schema = "<type>(<scope>): <summary>"
schema_pattern = "^([a-z]+)(\\([\\w\\-\\.]+\\))?:\\s.*"
bump_map = { "change" = "MINOR", "feat" = "MINOR", "fix" = "PATCH", "refactor" = "PATCH", "remove" = "PATCH", "revert" = "PATCH" }
bump_pattern = "^(change|feat|fix|refactor|remove|revert)"
change_type_order = ["change", "ci", "docs", "feat", "fix", "refactor", "remove", "revert"]
example = "change: this is a custom change type"
message_template = "{% if scope %}{{change_type}}({{scope}}): {{message}}{% else %}{{change_type}}: {{message}}{% endif %}{% if body %}\n\n{{body}}{% endif %}{% if is_breaking_change %}\n\nBREAKING CHANGE{% endif %}{% if footer %}\n\n{{footer}}{% endif %}"
schema = "<type>(<scope>): <summary>"
schema_pattern = "^([a-z]+)(\\([\\w\\-\\.]+\\))?:\\s.*"

[[tool.commitizen.customize.questions]]
choices = [
Expand Down Expand Up @@ -147,3 +142,11 @@
message = "Footer. Information about Breaking Changes and reference issues that this commit closes: (press [enter] to skip)"
name = "footer"
type = "input"

[tool.yamlfix]
comments_min_spaces_from_content = 1 # Minimum number of spaces between comments and content
line_length = 200 # Maximum line length before wrapping
preserve_quotes = true # Preserve quotes around string values if they are present
section_whitelines = 1 # Number of blank lines before and after sections
sequence_style = "keep_style" # Determines how sequences (lists) are formatted: 'flow_style', 'block_style', or 'keep_style'
whitelines = 1 # Number of blank lines between elements, useful for separating items

0 comments on commit 03bf74f

Please sign in to comment.