Skip to content

Commit f4dc23f

Browse files
authored
Merge pull request #3 from adolfo-ab/add-precommit-config
Add precommit config
2 parents cf397ba + 06a79e2 commit f4dc23f

File tree

4 files changed

+111
-7
lines changed

4 files changed

+111
-7
lines changed

.flake8

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[flake8]
2+
# UFN plugin must be run in serial
3+
jobs = 0
4+
max-line-length = 120
5+
6+
exclude =
7+
doc,
8+
.venv,
9+
.git,
10+
.yml,
11+
Pipfile.*,
12+
docs/*,
13+
14+
fcn_exclude_functions =
15+
re,
16+
logging,
17+
LOGGER,
18+
os,
19+
json,
20+
yaml,
21+
pytest,
22+
23+
enable-extensions =
24+
FCN,
25+
UFN,
26+
NIC,
27+
NIT,

.pre-commit-config.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
minimum_pre_commit_version: 3.3.0
2+
default_install_hook_types: [pre-commit, commit-msg]
3+
4+
default_language_version:
5+
python: python3
6+
7+
repos:
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: "v5.0.0"
10+
hooks:
11+
- id: check-merge-conflict
12+
- id: debug-statements
13+
- id: trailing-whitespace
14+
args: [--markdown-linebreak-ext=md] # Do not process Markdown files.
15+
- id: end-of-file-fixer
16+
- id: check-ast
17+
- id: check-builtin-literals
18+
- id: check-docstring-first
19+
- id: check-toml
20+
21+
- repo: https://github.com/PyCQA/flake8
22+
rev: "7.1.2"
23+
hooks:
24+
- id: flake8
25+
args: [--config=.flake8, '--ignore=FCN001,W503']
26+
additional_dependencies:
27+
[
28+
"git+https://github.com/RedHatQE/[email protected]",
29+
"flake8-mutable",
30+
]
31+
32+
- repo: https://github.com/Yelp/detect-secrets
33+
rev: v1.5.0
34+
hooks:
35+
- id: detect-secrets
36+
37+
- repo: https://github.com/astral-sh/ruff-pre-commit
38+
rev: v0.9.10
39+
hooks:
40+
- id: ruff
41+
- id: ruff-format
42+
43+
- repo: https://github.com/gitleaks/gitleaks
44+
rev: v8.24.0
45+
hooks:
46+
- id: gitleaks
47+
48+
- repo: https://github.com/pre-commit/mirrors-mypy
49+
rev: v1.15.0
50+
hooks:
51+
- id: mypy
52+
additional_dependencies: ["types-PyYAML", "types-requests"]
53+
exclude: ^(docs/|.*/test_.*)

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# New contributor guide
2+
3+
## pre-commit
4+
5+
In order to ensure proper and consistent code formatting, we use `pre-commit` in combination with tools like `ruff`, `flake8`, and `mypy`. When committing your code, make sure that all the pre-commit checks pass in your local environment.
6+
To install pre-commit:
7+
8+
```bash
9+
pre-commit install -t pre-commit -t commit-msg
10+
```
11+
12+
Run manually pre-commit:
13+
14+
```bash
15+
pre-commit run --all-files
16+
```

pyproject.toml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ requests = "^2.31.0"
1818

1919
[tool.poetry.group.dev.dependencies]
2020
pytest = "^7.4.2"
21-
black = "^23.9.1"
2221
isort = "^5.12.0"
2322
flake8 = "^6.1.0"
2423
mypy = "^1.5.1"
@@ -29,11 +28,6 @@ httpx = "^0.25.0"
2928
requires = ["poetry-core"]
3029
build-backend = "poetry.core.masonry.api"
3130

32-
[tool.black]
33-
line-length = 88
34-
target-version = ["py311"]
35-
include = '\.pyi?$'
36-
3731
[tool.isort]
3832
profile = "black"
3933
line_length = 88
@@ -44,8 +38,22 @@ warn_return_any = true
4438
warn_unused_configs = true
4539
disallow_untyped_defs = true
4640
disallow_incomplete_defs = true
41+
check_untyped_defs = true
42+
no_implicit_optional = true
43+
show_error_codes = true
44+
warn_unused_ignores = true
45+
46+
[tool.ruff]
47+
preview = true
48+
line-length = 120
49+
fix = true
50+
output-format = "grouped"
51+
extend-exclude = ["utilities/manifests"]
52+
53+
[tool.ruff.format]
54+
exclude = [".git", ".venv", ".mypy_cache", "__pycache__"]
4755

4856
[tool.pytest.ini_options]
4957
testpaths = ["tests"]
5058
python_files = "test_*.py"
51-
python_functions = "test_*"
59+
python_functions = "test_*"

0 commit comments

Comments
 (0)