Skip to content

Commit 1fcca9a

Browse files
committed
Added precommit hooks
1 parent 316202b commit 1fcca9a

File tree

9 files changed

+213
-104
lines changed

9 files changed

+213
-104
lines changed

.pre-commit-config.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.1.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- repo: https://github.com/pycqa/isort
7+
rev: 5.12.0
8+
hooks:
9+
- id: isort
10+
name: python isort
11+
pass_filenames: false
12+
always_run: true
13+
args: ["python"]
14+
- repo: https://github.com/psf/black
15+
rev: 23.9.1
16+
hooks:
17+
- id: black
18+
name: python black
19+
pass_filenames: false
20+
always_run: true
21+
args: ["python"]
22+
- repo: https://github.com/pre-commit/mirrors-mypy
23+
rev: v1.5.1
24+
hooks:
25+
- id: mypy
26+
name: python mypy
27+
always_run: true
28+
pass_filenames: false
29+
args: ["python"]
30+
- repo: https://github.com/astral-sh/ruff-pre-commit
31+
rev: v0.0.291
32+
hooks:
33+
- id: ruff
34+
name: ruff
35+
pass_filenames: false
36+
always_run: true
37+
args: ["python", "--fix"]
38+
- repo: local
39+
hooks:
40+
- id: fmt
41+
types:
42+
- rust
43+
name: rust fmt
44+
language: system
45+
entry: cargo
46+
pass_filenames: false
47+
args:
48+
- fmt
49+
- --
50+
- --config
51+
- use_try_shorthand=true,imports_granularity=Crate
52+
53+
- id: clippy
54+
types:
55+
- rust
56+
name: rust clippy
57+
language: system
58+
pass_filenames: false
59+
entry: cargo
60+
args:
61+
- clippy
62+
- -p
63+
- psqlpy
64+
- --
65+
- -W
66+
- clippy::all
67+
- -W
68+
- clippy::pedantic
69+
- -D
70+
- warnings
71+
72+
- id: check
73+
types:
74+
- rust
75+
name: rust cargo check
76+
language: system
77+
entry: cargo
78+
pass_filenames: false
79+
args:
80+
- check

pyproject.toml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,83 @@ features = ["pyo3/extension-module"]
3838
homepage = "https://github.com/qaspen-python/psqlpy"
3939
repository = "https://github.com/qaspen-python/psqlpy"
4040
documentation = "https://github.com/qaspen-python/psqlpy/blob/main/README.md"
41+
42+
[tool.isort]
43+
profile = "black"
44+
multi_line_output = 3
45+
46+
[tool.mypy]
47+
strict = true
48+
mypy_path = "python"
49+
ignore_missing_imports = true
50+
allow_subclassing_any = true
51+
allow_untyped_calls = true
52+
pretty = true
53+
show_error_codes = true
54+
implicit_reexport = true
55+
allow_untyped_decorators = true
56+
warn_return_any = false
57+
warn_unused_ignores = false
58+
59+
[tool.ruff]
60+
# List of enabled rulsets.
61+
# See https://docs.astral.sh/ruff/rules/ for more information.
62+
select = [
63+
"E", # Error
64+
"F", # Pyflakes
65+
"W", # Pycodestyle
66+
"C90", # McCabe complexity
67+
"N", # pep8-naming
68+
"D", # Pydocstyle
69+
"ANN", # Pytype annotations
70+
"S", # Bandit
71+
"B", # Bugbear
72+
"COM", # Commas
73+
"C4", # Comprehensions
74+
"ISC", # Implicit string concat
75+
"PIE", # Unnecessary code
76+
"T20", # Catch prints
77+
"PYI", # validate pyi files
78+
"Q", # Checks for quotes
79+
"RSE", # Checks raise statements
80+
"RET", # Checks return statements
81+
"SLF", # Self checks
82+
"SIM", # Simplificator
83+
"PTH", # Pathlib checks
84+
"ERA", # Checks for commented out code
85+
"PL", # PyLint checks
86+
"RUF", # Specific to Ruff checks
87+
]
88+
ignore = [
89+
"D105", # Missing docstring in magic method
90+
"D107", # Missing docstring in __init__
91+
"D211", # No blank lines allowed before class docstring
92+
"D212", # Multi-line docstring summary should start at the first line
93+
"D401", # First line should be in imperative mood
94+
"D104", # Missing docstring in public package
95+
"D100", # Missing docstring in public module
96+
"ANN102", # Missing type annotation for self in method
97+
"ANN101", # Missing type annotation for argument
98+
"ANN401", # typing.Any are disallowed in `**kwargs
99+
"PLR0913", # Too many arguments for function call
100+
"D106", # Missing docstring in public nested class
101+
]
102+
exclude = [".venv/"]
103+
mccabe = { max-complexity = 10 }
104+
line-length = 88
105+
106+
[tool.ruff.per-file-ignores]
107+
"python/psqlpy/*" = ["PYI021"]
108+
"python/tests/*" = [
109+
"S101", # Use of assert detected
110+
"S608", # Possible SQL injection vector through string-based query construction
111+
"D103", # Missing docstring in public function
112+
"S311", # Standard pseudo-random generators are not suitable for security/cryptographic purposes
113+
]
114+
115+
[tool.ruff.pydocstyle]
116+
convention = "pep257"
117+
ignore-decorators = ["typing.overload"]
118+
119+
# [tool.ruff.pylint]
120+
# allow-magic-value-types = ["int", "str", "float", "tuple"]

python/psqlpy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from ._internal import PSQLPool, QueryResult, Transaction, IsolationLevel, ReadVariant
1+
from ._internal import IsolationLevel, PSQLPool, QueryResult, ReadVariant, Transaction
22

33
__all__ = [
44
"PSQLPool",
55
"QueryResult",
66
"Transaction",
77
"IsolationLevel",
88
"ReadVariant",
9-
]
9+
]

0 commit comments

Comments
 (0)