From f5bb7dea61067c85008d2e21ad0182c92c9dae47 Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Thu, 19 May 2022 08:38:00 +0200 Subject: [PATCH] global: add pyprojet.toml and pre-commit.yaml --- .pre-commit-config.yaml | 53 +++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 15 ++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..9c8f9d021c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,53 @@ +# See https://pre-commit.com for more information, specially https://pre-commit.com/#pre-commit-run for manual trigger +# Some example useful invocations: +# pre-commit run: this is what pre-commit runs by default when committing. This will run all hooks against currently staged files. +# pre-commit run --all-files: run all the hooks against all the files. This is a useful invocation if you are using pre-commit in CI. +# pre-commit run check-executables-have-shebangs: run the check-executables-have-shebangs hook against all staged files. + +# Files or directory we want to excude from checking +exclude: | + (?x)( + ^modules/ | + ^build/ | + ^cmake-build-debug/ | + \.m | + ^libraries/AP_HAL_ChibiOS/hwdef/scripts/ + ) + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.2.0 + hooks: + #- id: trailing-whitespace + #- id: end-of-file-fixer + - id: mixed-line-ending + name: Check line ending character (LF) + args: ["--fix=lf"] + types_or: [python, c, c++, shell] + - id: check-added-large-files + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + exclude: | + (?x)^( + .*\/wscript | + wscript + )$ + - id: check-merge-conflict + - id: check-xml + - id: check-yaml + +# Use to sort python imports by name and put system import first. + - repo: https://github.com/pycqa/isort + rev: 5.10.1 + hooks: + - id: isort + args: [--check-only] + name: isort (python) + +# Use to check python typing to show errors. + - repo: https://github.com/pre-commit/mirrors-mypy + rev: 'v0.950' + hooks: + - id: mypy + args: [--no-strict-optional, --ignore-missing-imports] + additional_dependencies: [types-PyYAML, types-requests] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..74d3c39462 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[tool.isort] +profile = "black" +skip = ["./modules/", "./build/"] + +[tool.black] +line-length = 120 + +[tool.mypy] +ignore_missing_imports = true +exclude = [ + 'modules/', + 'build/', + 'cmake-build-debug/', + '/setup\.py$' +]