Skip to content

Commit

Permalink
Use pydocstyle Google convention
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain-S committed Aug 15, 2023
1 parent 2905684 commit 0912e0e
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ repos:
language: system
types: ['markdown']
exclude: .github/
- id: pydocstyle
name: pydocstyle
entry: poetry run pydocstyle --convention=google
language: system
types: ['python']
30 changes: 29 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pytest-mock = "^3.6.1"
requests = "^2.25.1"
safety = "^2.3.1"
sqlalchemy-stubs = "^0.3"
pydocstyle = "^6.3.0"

[tool.isort]
profile = "black"
Expand Down
3 changes: 1 addition & 2 deletions rctab/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,5 @@ async def get_documentation(_: Dict = Depends(user_authenticated)) -> HTMLRespon

@app.get("/redoc", include_in_schema=False)
async def get_redocumentation(_: Dict = Depends(user_authenticated)) -> HTMLResponse:
"""Serves redoc API docs."""

"""Serves Redoc API docs."""
return get_redoc_html(openapi_url="/openapi.json", title="docs")
3 changes: 2 additions & 1 deletion rctab/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Utility functions for the RCTab API."""
import functools
import logging
from contextlib import contextmanager
Expand All @@ -24,7 +25,7 @@ def wrapping_logic(statement: Any) -> Generator:
def _db_select(
*args: Any, execute: bool = True, raise_404: bool = True, **kwargs: Any
) -> Coroutine:
"Select and raise a 404 if no data is returned"
"""Select and raise a 404 if no data is returned."""
statement = func(*args, **kwargs)

if execute:
Expand Down
1 change: 1 addition & 0 deletions tests/test_crud/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Test the database-related functionality."""
7 changes: 7 additions & 0 deletions tests/test_routes/api_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
def assert_subscription_status(
client: TestClient, expected_details: SubscriptionDetails
) -> None:
"""Assert that the subscription details are as expected."""
result = client.get(
PREFIX + "/subscription",
params={"sub_id": str(expected_details.subscription_id)},
Expand All @@ -43,6 +44,7 @@ def assert_subscription_status(


def create_subscription(client: TestClient, subscription_id: UUID) -> Response:
"""Create a subscription record."""
return client.post(
PREFIX + "/subscription",
json={"sub_id": str(subscription_id)},
Expand All @@ -57,6 +59,7 @@ def create_subscription_detail(
role_assignments: Optional[Tuple[RoleAssignment, ...]] = (),
display_name: str = "sub display name",
) -> Response:
"""Create a subscription detail record."""
return client.post(
"accounting" + "/all-status",
content=AllSubscriptionStatus(
Expand All @@ -76,6 +79,7 @@ def create_subscription_detail(
def set_persistence(
client: TestClient, subscription_id: UUID, always_on: bool
) -> Response:
"""Set the persistence of a subscription."""
return client.post(
PREFIX + "/persistent",
json={"sub_id": str(subscription_id), "always_on": always_on},
Expand All @@ -93,6 +97,7 @@ def create_approval(
currency: str = "GBP",
force: bool = False,
) -> Response:
"""Create an approval for a subscription."""
return client.post(
PREFIX + "/approve",
json={
Expand All @@ -114,6 +119,7 @@ def create_allocation(
ticket: str,
amount: float,
) -> Response:
"""Create an allocation for a subscription."""
return client.post(
PREFIX + "/topup",
json={"sub_id": str(subscription_id), "ticket": ticket, "amount": amount},
Expand All @@ -128,6 +134,7 @@ def create_usage(
amortised_cost: float = 0.0,
date: datetime.date = datetime.date.today(),
) -> Response:
"""Create a usage record for a subscription."""
usage = Usage(
id=str(uuid4()),
name="test",
Expand Down

0 comments on commit 0912e0e

Please sign in to comment.