Skip to content

Commit 2d88b17

Browse files
committed
style/chore: fix, update linters, fix lingering static type bugs
1 parent 517a6e8 commit 2d88b17

File tree

14 files changed

+37
-29
lines changed

14 files changed

+37
-29
lines changed

.github/workflows/maintests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ jobs:
4141

4242

4343
- name: Run tests
44-
run: uv run pytest tests --ignore-glob='**/*api_calls*' -m "not api_side_ci"
44+
run: uv run pytest tests --ignore-glob='**/*api_calls*' -m "not api_side_ci"

.pre-commit-config.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v5.0.0
3+
rev: v6.0.0
44
hooks:
55
- id: check-yaml
66
exclude: ^mkdocs\.yml$
77
- id: end-of-file-fixer
88
- id: trailing-whitespace
9-
- repo: https://github.com/psf/black
10-
rev: 24.10.0
11-
hooks:
12-
- id: black
139
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.7.2
10+
rev: v0.14.10
1511
hooks:
16-
- id: ruff
12+
- id: ruff-check
13+
- id: ruff-format
1714
- repo: https://github.com/pre-commit/mirrors-mypy
18-
rev: 'v1.13.0'
15+
rev: v1.19.1
1916
hooks:
2017
- id: mypy
2118
args: [., --strict, --ignore-missing-imports, --exclude=^codegen]
@@ -30,10 +27,11 @@ repos:
3027
types-setuptools,
3128
types-urllib3,
3229
types-aiofiles,
30+
types-PyYAML,
3331
StrEnum,
3432
horde_model_reference>=2.0.0,
3533
]
3634
- repo: https://github.com/gauge-sh/tach-pre-commit
37-
rev: v0.27.0
35+
rev: v0.29.0
3836
hooks:
3937
- id: tach

docs/.pages

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ nav:
2121
- SDK Client Design: concepts/client_design
2222
- Backend Values Mappers: concepts/backend_values_mappers
2323
- horde_sdk
24-
24+
2525
- GitHub Repo: 'https://github.com/Haidra-Org/horde-sdk'
2626

2727
order: desc

docs/concepts/backend_values_mappers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def map_to_example_backend_sampler(self, sdk_sampler: KNOWN_IMAGE_SAMPLERS) -> K
131131
"""Maps an SDK sampler to a backend sampler."""
132132
...
133133

134-
...
134+
...
135135
```
136136

137137
#### Understanding `_map_value` and `_is_valid_value`

docs/concepts/client_design.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ classDiagram
1212
class GenericHordeAPIManualClient
1313
1414
class GenericAsyncHordeAPIManualClient
15-
class GenericHordeAPISession
15+
class GenericHordeAPISession
1616
17-
class GenericAsyncHordeAPISession
17+
class GenericAsyncHordeAPISession
1818
1919
BaseHordeAPIClient <|-- GenericHordeAPIManualClient
2020
BaseHordeAPIClient <|-- GenericAsyncHordeAPIManualClient

docs/concepts/style_guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Many classes contain standardized prefixes, suffixes, or identifiers within thei
162162
- For example, methods which are known to rely on external resources (e.g., network calls, file I/O) should document the exceptions that may be raised in the event of a failure.
163163
- It is **not** expected that every conceivable exception raised from a particular call hierarchy is documented, but rather those that are most likely to occur and can be reasonably anticipated.
164164
- A method that opens a file should document `FileNotFoundError` and `IOError` in its `Raises` section, while network-related methods should document `ConnectionError`, `TimeoutError`, and other relevant exceptions.
165-
165+
166166
### API Model Specific Documentation
167167

168168
Many docstrings in the SDK have additional requirements when they are related to API models or requests/responses. While these rules would be difficult to remember, they are luckily enforced by CI and the `horde_sdk.meta` module has helper functions to assist in generating the required docstrings. The correct docstrings will also be emitted by the `object_verify` tests. Be sure to run the tests with `-s` to see the output.

docs/worker/generation_states_flow.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ flowchart TD
1414
1515
NOT_STARTED@{shape: subproc}
1616
PRELOADING@{shape: subproc}
17-
PRELOADING_COMPLETE@{shape: subproc}
17+
PRELOADING_COMPLETE@{shape: subproc}
1818
PENDING_POST_PROCESSING@{ shape: subproc}
1919
POST_PROCESSING@{ shape: subproc}
2020
GENERATING@{ shape: subproc}
@@ -119,7 +119,7 @@ Good:
119119
- Here, the worker encountered an error during preloading, attempted to recover, but failed again and then aborted the job. Note that you can set the intended number of retries in worker job configuration. See the `HordeWorkerJobConfig` class and the `state_error_limits` arg in a generation class constructor for more details.
120120
- `NOT_STARTED` -> `PRELOADING` -> `USER_REQUESTED_ABORT` -> `USER_ABORT_COMPLETE`
121121
- In this case, the user who created the job requested an abort, and the worker was able to complete the abort process successfully.
122-
122+
123123
Bad:
124124

125125
- `NOT_STARTED` -> `PRELOADING` -> `ERROR` -> `GENERATING`

docs/worker/generations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ These functions return the transitioned to state.
8585
#### Important Notes on State Transitions
8686

8787
- **Strict Order:** You must call state transition methods in the correct sequence. For example, you cannot call `on_generating()` before `on_preloading_complete()`. This strictness helps catch workflow errors early. Out-of-order calls almost always indicate a problem in your logic or resource handling.
88-
- **Error Handling:** If an error occurs at any step, use `on_error(failed_message="...")` to move the generation into the `ERROR` state. This lets you handle errors gracefully and, if needed, recover. To continue after an error, you must return to the most recent valid state before proceeding.
88+
- **Error Handling:** If an error occurs at any step, use `on_error(failed_message="...")` to move the generation into the `ERROR` state. This lets you handle errors gracefully and, if needed, recover. To continue after an error, you must return to the most recent valid state before proceeding.
8989
- For example, if you are in the `GENERATING` state and an error occurs, call `on_error()` to enter `ERROR`, then call `on_generating()` again to retry.
9090
- **Dynamic States:** Some transition methods, such as `on_generation_work_complete()`, may lead to different next states depending on context (e.g., whether post-processing is required). The class handles these decisions internally, so you don’t need to manually select the next state.
9191
- **Manual States:** You can use the generic `step(state)` or `on_state(state)` methods to transition to a specific state. However, you are responsible for ensuring the transition is valid—these methods bypass some of the built-in checks.
@@ -346,7 +346,7 @@ flowchart TD
346346
347347
NOT_STARTED@{shape: subproc}
348348
PRELOADING@{shape: subproc}
349-
PRELOADING_COMPLETE@{shape: subproc}
349+
PRELOADING_COMPLETE@{shape: subproc}
350350
PENDING_POST_PROCESSING@{ shape: subproc}
351351
POST_PROCESSING@{ shape: subproc}
352352
GENERATING@{ shape: subproc}
@@ -451,7 +451,7 @@ Good:
451451
- Here, the worker encountered an error during preloading, attempted to recover, but failed again and then aborted the job. Note that you can set the intended number of retries in worker job configuration. See the `HordeWorkerJobConfig` class and the `state_error_limits` arg in a generation class constructor for more details.
452452
- `NOT_STARTED` -> `PRELOADING` -> `USER_REQUESTED_ABORT` -> `USER_ABORT_COMPLETE`
453453
- In this case, the user who created the job requested an abort, and the worker was able to complete the abort process successfully.
454-
454+
455455
Bad:
456456

457457
- `NOT_STARTED` -> `PRELOADING` -> `ERROR` -> `GENERATING`

horde_sdk/ai_horde_api/apimodels/documents.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515

1616
class DocumentFormat(StrEnum):
17+
"""The supported formats for a document."""
18+
1719
html = "html"
1820
markdown = "markdown"
1921

@@ -25,7 +27,7 @@ class HordeDocument(HordeResponseBaseModel):
2527
- /v2/documents/privacy | AIHordeGetPrivacyPolicyRequest [GET] -> 200
2628
2729
v2 API Model: `HordeDocument`
28-
"""
30+
""" # noqa: D205, D415
2931

3032
html: str | None = None
3133
"""The HTML content of the document, if requested."""
@@ -39,6 +41,8 @@ def get_api_model_name(cls) -> str:
3941

4042

4143
class AIHordeDocumentRequestMixin(HordeAPIObjectBaseModel):
44+
"""Mixin for requests that retrieve a document from the AI Horde API."""
45+
4246
format: DocumentFormat | str = DocumentFormat.html
4347

4448
"""The format of the document to return. Default is markdown."""

horde_sdk/ai_horde_api/apimodels/generate/text/async_.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ class _BasePayloadKoboldMixin(HordeAPIData):
188188

189189
@Unhashable
190190
class ModelPayloadRootKobold(_BasePayloadKoboldMixin):
191+
"""Base model for KoboldAI generation payloads."""
192+
191193
n: int | None = Field(default=None, examples=[1], ge=1, le=20)
192194
"""The number of generations to produce."""
193195

@@ -204,7 +206,7 @@ class ModelPayloadRootKobold(_BasePayloadKoboldMixin):
204206

205207
@Unhashable
206208
class ModelGenerationInputKobold(ModelPayloadRootKobold):
207-
pass
209+
"""API Parity intermediate model for generation input."""
208210

209211

210212
class TextGenerateAsyncDryRunResponse(HordeResponseBaseModel):

0 commit comments

Comments
 (0)