Skip to content

Commit

Permalink
Added precommit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
chandr-andr committed Feb 21, 2024
1 parent 316202b commit 1fcca9a
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 104 deletions.
80 changes: 80 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
- id: trailing-whitespace
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: python isort
pass_filenames: false
always_run: true
args: ["python"]
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
name: python black
pass_filenames: false
always_run: true
args: ["python"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
name: python mypy
always_run: true
pass_filenames: false
args: ["python"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.291
hooks:
- id: ruff
name: ruff
pass_filenames: false
always_run: true
args: ["python", "--fix"]
- repo: local
hooks:
- id: fmt
types:
- rust
name: rust fmt
language: system
entry: cargo
pass_filenames: false
args:
- fmt
- --
- --config
- use_try_shorthand=true,imports_granularity=Crate

- id: clippy
types:
- rust
name: rust clippy
language: system
pass_filenames: false
entry: cargo
args:
- clippy
- -p
- psqlpy
- --
- -W
- clippy::all
- -W
- clippy::pedantic
- -D
- warnings

- id: check
types:
- rust
name: rust cargo check
language: system
entry: cargo
pass_filenames: false
args:
- check
80 changes: 80 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,83 @@ features = ["pyo3/extension-module"]
homepage = "https://github.com/qaspen-python/psqlpy"
repository = "https://github.com/qaspen-python/psqlpy"
documentation = "https://github.com/qaspen-python/psqlpy/blob/main/README.md"

[tool.isort]
profile = "black"
multi_line_output = 3

[tool.mypy]
strict = true
mypy_path = "python"
ignore_missing_imports = true
allow_subclassing_any = true
allow_untyped_calls = true
pretty = true
show_error_codes = true
implicit_reexport = true
allow_untyped_decorators = true
warn_return_any = false
warn_unused_ignores = false

[tool.ruff]
# List of enabled rulsets.
# See https://docs.astral.sh/ruff/rules/ for more information.
select = [
"E", # Error
"F", # Pyflakes
"W", # Pycodestyle
"C90", # McCabe complexity
"N", # pep8-naming
"D", # Pydocstyle
"ANN", # Pytype annotations
"S", # Bandit
"B", # Bugbear
"COM", # Commas
"C4", # Comprehensions
"ISC", # Implicit string concat
"PIE", # Unnecessary code
"T20", # Catch prints
"PYI", # validate pyi files
"Q", # Checks for quotes
"RSE", # Checks raise statements
"RET", # Checks return statements
"SLF", # Self checks
"SIM", # Simplificator
"PTH", # Pathlib checks
"ERA", # Checks for commented out code
"PL", # PyLint checks
"RUF", # Specific to Ruff checks
]
ignore = [
"D105", # Missing docstring in magic method
"D107", # Missing docstring in __init__
"D211", # No blank lines allowed before class docstring
"D212", # Multi-line docstring summary should start at the first line
"D401", # First line should be in imperative mood
"D104", # Missing docstring in public package
"D100", # Missing docstring in public module
"ANN102", # Missing type annotation for self in method
"ANN101", # Missing type annotation for argument
"ANN401", # typing.Any are disallowed in `**kwargs
"PLR0913", # Too many arguments for function call
"D106", # Missing docstring in public nested class
]
exclude = [".venv/"]
mccabe = { max-complexity = 10 }
line-length = 88

[tool.ruff.per-file-ignores]
"python/psqlpy/*" = ["PYI021"]
"python/tests/*" = [
"S101", # Use of assert detected
"S608", # Possible SQL injection vector through string-based query construction
"D103", # Missing docstring in public function
"S311", # Standard pseudo-random generators are not suitable for security/cryptographic purposes
]

[tool.ruff.pydocstyle]
convention = "pep257"
ignore-decorators = ["typing.overload"]

# [tool.ruff.pylint]
# allow-magic-value-types = ["int", "str", "float", "tuple"]
4 changes: 2 additions & 2 deletions python/psqlpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from ._internal import PSQLPool, QueryResult, Transaction, IsolationLevel, ReadVariant
from ._internal import IsolationLevel, PSQLPool, QueryResult, ReadVariant, Transaction

__all__ = [
"PSQLPool",
"QueryResult",
"Transaction",
"IsolationLevel",
"ReadVariant",
]
]
Loading

0 comments on commit 1fcca9a

Please sign in to comment.