diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b93a3a5..62947c0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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'] diff --git a/poetry.lock b/poetry.lock index 5cf0839..f6a6a76 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2493,6 +2493,23 @@ typing-extensions = ">=4.2.0" dotenv = ["python-dotenv (>=0.10.4)"] email = ["email-validator (>=1.0.3)"] +[[package]] +name = "pydocstyle" +version = "6.3.0" +description = "Python docstring style checker" +optional = false +python-versions = ">=3.6" +files = [ + {file = "pydocstyle-6.3.0-py3-none-any.whl", hash = "sha256:118762d452a49d6b05e194ef344a55822987a462831ade91ec5c06fd2169d019"}, + {file = "pydocstyle-6.3.0.tar.gz", hash = "sha256:7ce43f0c0ac87b07494eb9c0b462c0b73e6ff276807f204d6b53edc72b7e44e1"}, +] + +[package.dependencies] +snowballstemmer = ">=2.2.0" + +[package.extras] +toml = ["tomli (>=1.2.3)"] + [[package]] name = "pyflakes" version = "2.3.1" @@ -3153,6 +3170,17 @@ files = [ {file = "sniffio-1.3.0.tar.gz", hash = "sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101"}, ] +[[package]] +name = "snowballstemmer" +version = "2.2.0" +description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." +optional = false +python-versions = "*" +files = [ + {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"}, + {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, +] + [[package]] name = "sortedcontainers" version = "2.4.0" @@ -3701,4 +3729,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.10 <3.12" -content-hash = "7fb2a1b2601f83e44af9a05d6033785f2e377d0626b77bc4cdefef4857a576ea" +content-hash = "049168b9b2c4a52107663cd6ee0ebe97d252d5855a0560bd6b8553860403f53f" diff --git a/pyproject.toml b/pyproject.toml index da2e32e..d6b6cf7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/rctab/main.py b/rctab/main.py index 86ee709..d128bcf 100644 --- a/rctab/main.py +++ b/rctab/main.py @@ -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") diff --git a/rctab/utils.py b/rctab/utils.py index a946bcb..1642b71 100644 --- a/rctab/utils.py +++ b/rctab/utils.py @@ -1,3 +1,4 @@ +"""Utility functions for the RCTab API.""" import functools import logging from contextlib import contextmanager @@ -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: diff --git a/tests/test_crud/__init__.py b/tests/test_crud/__init__.py index e69de29..8e5ee9e 100644 --- a/tests/test_crud/__init__.py +++ b/tests/test_crud/__init__.py @@ -0,0 +1 @@ +"""Test the database-related functionality.""" diff --git a/tests/test_routes/api_calls.py b/tests/test_routes/api_calls.py index fb40b44..3176475 100644 --- a/tests/test_routes/api_calls.py +++ b/tests/test_routes/api_calls.py @@ -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)}, @@ -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)}, @@ -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( @@ -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}, @@ -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={ @@ -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}, @@ -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",