Skip to content

Commit

Permalink
Merge pull request #1123 from VWS-Python/more-precommit-hooks
Browse files Browse the repository at this point in the history
Add more pre-commit hooks
  • Loading branch information
adamtheturtle authored Oct 8, 2024
2 parents 5c888ba + 4a87aba commit e73bd29
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .checkmake-config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[minphony]
disabled = true
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ repos:
- id: file-contents-sorter
files: spelling_private_dict\.txt$
- id: trailing-whitespace
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- id: rst-backticks
- repo: https://github.com/mrtazz/checkmake.git
rev: 0.2.2
hooks:
- id: checkmake
args: ["--config", ".checkmake-config.ini"]
- repo: https://github.com/google/yamlfmt
rev: v0.13.0
hooks:
- id: yamlfmt
- repo: local
hooks:
- id: actionlint
Expand All @@ -33,6 +49,13 @@ repos:
types_or: [yaml]
additional_dependencies: ["uv"]

- id: docformatter
name: docformatter
entry: uv run --extra=dev -m docformatter --in-place
language: python
types_or: [python]
additional_dependencies: ["uv"]

- id: shellcheck
name: shellcheck
entry: uv run --extra=dev shellcheck --shell=bash --exclude=SC1017
Expand Down Expand Up @@ -260,6 +283,7 @@ ci:
- ruff-check-fix-docs
- ruff-format-fix
- ruff-format-fix-docs
- docformatter
- shellcheck
- shellcheck-docs
- shfmt
Expand Down
5 changes: 5 additions & 0 deletions .yamlfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
formatter:
include_document_start: true
retain_line_breaks_single: true
trim_trailing_whitespace: true
end_of_file_newline: true
1 change: 1 addition & 0 deletions codecov.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
coverage:
status:
patch:
Expand Down
7 changes: 4 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Setup for test suite."""
"""
Setup for test suite.
"""

import uuid
from collections.abc import Generator
Expand All @@ -20,8 +22,7 @@
def fixture_mock_vws(
monkeypatch: pytest.MonkeyPatch,
) -> Generator[None]:
"""
Yield a mock VWS.
"""Yield a mock VWS.
The keys used here match the keys in the documentation.
"""
Expand Down
4 changes: 3 additions & 1 deletion docs/source/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"""Documentation."""
"""
Documentation.
"""
4 changes: 3 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python3
"""Configuration for Sphinx."""
"""
Configuration for Sphinx.
"""

import importlib.metadata

Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ optional-dependencies.dev = [
"deptry==0.20.0",
"doc8==1.1.2",
"doccmd==2024.10.8.12",
"docformatter==1.7.5",
"freezegun==1.5.1",
"furo==2024.8.6",
"interrogate==1.7.0",
Expand Down Expand Up @@ -240,6 +241,9 @@ spelling-private-dict-file = 'spelling_private_dict.txt'
# --spelling-private-dict-file option instead of raising a message.
spelling-store-unknown-words = 'no'

[tool.docformatter]
make-summary-multi-line = true

[tool.check-manifest]

ignore = [
Expand Down
9 changes: 5 additions & 4 deletions readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
version: 2

build:
Expand All @@ -7,10 +8,10 @@ build:

python:
install:
- method: pip
path: .
extra_requirements:
- dev
- method: pip
path: .
extra_requirements:
- dev

sphinx:
builder: html
Expand Down
8 changes: 6 additions & 2 deletions src/vws_auth_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Authorization helpers."""
"""
Authorization helpers.
"""

import base64
import email.utils
Expand All @@ -10,7 +12,9 @@

@beartype
def _compute_hmac_base64(key: bytes, data: bytes) -> bytes:
"""Return the Base64 encoded HMAC-SHA1 hash of `data` using the `key`."""
"""
Return the Base64 encoded HMAC-SHA1 hash of `data` using the `key`.
"""
hashed = hmac.new(key=key, msg=None, digestmod=hashlib.sha1)
hashed.update(msg=data)
return base64.b64encode(s=hashed.digest())
Expand Down
4 changes: 3 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"""Tests for authorization tools."""
"""
Tests for authorization tools.
"""
8 changes: 5 additions & 3 deletions tests/test_vws_auth_tools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Tests for authorization tools."""
"""
Tests for authorization tools.
"""

import datetime
from zoneinfo import ZoneInfo
Expand Down Expand Up @@ -42,8 +44,8 @@ def test_rfc_1123_date() -> None:
def test_authorization_header(content: bytes | str) -> None:
"""The Authorization header is constructed as documented.
This example has been run on known-working code and so any refactor should
continue to pass this test.
This example has been run on known-working code and so any refactor
should continue to pass this test.
"""
access_key = "my_access_key"
# Ignore "Possible hardcoded password" as it is appropriate here.
Expand Down

0 comments on commit e73bd29

Please sign in to comment.