Skip to content

Commit

Permalink
Add doc lint check to pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
drew887 committed Apr 15, 2022
1 parent 720983b commit 011587f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: run lint checks
run: poetry run black --check alpaca/ tests/
- name: build doc html to lint for errors
run: pushd docs && poetry run make html SPHINXOPTS="-W" && popd
run: ./tools/scripts/generate-docs.sh

tests-ci:
strategy:
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ repos:
entry: "poetry run pytest"
pass_filenames: false
always_run: true
- id: doc check
name: sphinx doc check
language: system
entry: "./tools/scripts/generate-docs.sh"
pass_filenames: false
always_run: true
18 changes: 16 additions & 2 deletions alpaca/broker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def __init__(
base_url: BaseURL = (
BaseURL.BROKER_SANDBOX if sandbox else BaseURL.BROKER_PRODUCTION
)

# TODO: Actually check raw_data everywhere
super().__init__(api_key, secret_key, api_version, base_url, sandbox, raw_data)

def create_account(self, account_data: AccountCreationRequest) -> Account:
Expand Down Expand Up @@ -116,5 +118,17 @@ def update_account(

return Account(**response)

def delete_account(self) -> Account:
pass
def delete_account(self, account_id: Union[UUID, str]) -> None:
"""
Delete an Account by its id.
As the api itself returns a 204 on success this function returns nothing in the successful case and will raise
and exception in any other case.
Args:
account_id (Union[UUID, str]): the id of the Account you wish to delete. str values will attempt to be
upcast to UUID to validate.
Returns:
None:
"""
1 change: 1 addition & 0 deletions alpaca/broker/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ def to_request_fields(self) -> dict:
{contact: {city: None, country: None...}, etc}
we generate just:
{trusted_contact:{given_name: "new value"}}
Returns:
dict: a dict containing any set fields
"""
Expand Down
4 changes: 4 additions & 0 deletions tests/broker/test_broker_client_accounts_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,7 @@ def test_update_account_validates_non_empty_request(reqmock, client: BrokerClien
client.update_account(account_id, update_data)

assert str(e.value) == "update_data must contain at least 1 field to change"


def test_delete_account(reqmock, client: BrokerClient):
pass
14 changes: 14 additions & 0 deletions tools/scripts/generate-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -e

#make sure we're in the root of our repo
pushd "$(dirname "$0")"/../../docs >>/dev/null

set +e

#clean any local files to prevent cached errors
poetry run make clean

#run make html with a flag to make sphinx treat warnings as errors instead of generating incomplete docs
poetry run make html SPHINXOPTS="-W"

0 comments on commit 011587f

Please sign in to comment.