Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 79
IndentWidth: 4
StatementAttributeLikeMacros:
# Defined in Include/pyport.h
- Py_DEPRECATED
- _Py_HOT_FUNCTION
- Py_ALWAYS_INLINE
- Py_NO_INLINE
- Py_ALIGNED
- Py_GCC_ATTRIBUTE
- _Py_NO_RETURN
- _Py_FALLTHROUGH
StatementMacros:
- PyObject_HEAD
- PyObject_VAR_HEAD
- PyException_HEAD
- _PyTZINFO_HEAD
- _PyDateTime_TIMEHEAD
- _PyDateTime_DATETIMEHEAD
- _PyGenObject_HEAD
- Window_NoArgNoReturnFunction
- Window_NoArgTrueFalseFunction
- Window_NoArgNoReturnVoidFunction
- Window_NoArg2TupleReturnFunction
- Window_OneArgNoReturnVoidFunction
- Window_OneArgNoReturnFunction
- Window_TwoArgNoReturnFunction
TabWidth: 4
UseTab: Never
WhitespaceSensitiveMacros:
- _Py_XSTRINGIFY
- Py_STRINGIFY
IndentExternBlock: NoIndent
AlwaysBreakAfterReturnType: All
BreakBeforeBraces: Linux
BinPackArguments: false
...
27 changes: 17 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

ci:
autoupdate_schedule: quarterly
skip:
- clang-format

repos:
- repo: https://github.com/python-jsonschema/check-jsonschema.git
Expand Down Expand Up @@ -29,15 +31,18 @@ repos:
args:
- --strict

- repo: https://github.com/PyCQA/flake8.git
rev: 7.2.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.12.0
hooks:
- id: flake8
alias: flake8-no-wps
name: flake8 WPS-excluded
additional_dependencies:
- flake8-pyi ~= 24.1.0
- flake8-pytest-style ~= 1.7.2
- id: ruff-check
args: ["--fix"]
exclude: >-
(?x)
^
tools/upgrade_pythoncapi\.py
$
- id: ruff-format
exclude: >-
(?x)
^
Expand Down Expand Up @@ -108,7 +113,10 @@ repos:
types:
- file
- rst

- repo: https://github.com/cpp-linter/cpp-linter-hooks
rev: v0.8.0
hooks:
- id: clang-format
- repo: https://github.com/pre-commit/mirrors-mypy.git
rev: v1.15.0
hooks:
Expand Down Expand Up @@ -144,5 +152,4 @@ repos:
- --cobertura-xml-report=.tox/.tmp/.mypy/python-3.11
- --html-report=.tox/.tmp/.mypy/python-3.11
pass_filenames: false

...
1 change: 1 addition & 0 deletions CHANGES/1123.contrib
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Setup pre-commit hook for auto-formatting both Python and C code.
21 changes: 1 addition & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,9 @@ all: test
pip install -r requirements/dev.txt
@touch .install-deps


isort-check:
@if ! isort --check $(SRC); then \
echo "Import sort errors, run 'make fmt' to fix them!!!"; \
isort --diff --check $(SRC); \
false; \
fi

black-check:
@if ! isort --check $(SRC); then \
echo "black errors, run 'make fmt' to fix them!!!"; \
black -t py35 --diff --check $(SRC); \
false; \
fi

lint: black-check isort-check
lint:
python -Im pre_commit run --all-files --show-diff-on-failure

fmt:
black -t py35 $(SRC)
isort $(SRC)

.develop: .install-deps $(shell find multidict -type f)
pip install -e .
@touch .develop
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/istr.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def add_impl_option(cmd, args):
runner = perf.Runner(add_cmdline_args=add_impl_option)

parser = runner.argparser
parser.description = "Allows to measure performance of " "istr implementations"
parser.description = "Allows to measure performance of istr implementations"
parser.add_argument(
"--impl",
choices=sorted(IMPLEMENTATIONS),
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def _replace_missing_aiohttp_hdrs_reference(
node: pending_xref,
contnode: literal,
) -> "reference | None":
if (node.get('refdomain'), node.get('reftype')) != ("py", "mod"):
if (node.get("refdomain"), node.get("reftype")) != ("py", "mod"):
return None

ref_target = node.get("reftarget", "")
Expand All @@ -401,7 +401,7 @@ def _replace_missing_aiohttp_hdrs_reference(


def setup(app: Sphinx) -> dict[str, bool | str]:
app.connect('missing-reference', _replace_missing_aiohttp_hdrs_reference)
app.connect("missing-reference", _replace_missing_aiohttp_hdrs_reference)

return {
"version": "builtin",
Expand Down
Loading
Loading