feat: add type hints to all public functions in trustgraph/base (#803)

feat: add type hints to all public functions in trustgraph/base

Add type annotations to 23 modules covering:
- Metrics classes (ConsumerMetrics, ProducerMetrics, etc.)
- Spec classes (ConsumerSpec, ProducerSpec, SubscriberSpec, etc.)
- Service classes with add_args() and run() methods
- Utility functions (logging, pubsub, clients)
- AsyncProcessor methods

All 93 public functions now fully typed.

Refs #785

* refactor: deduplicate imports and move __future__ after docstrings

Addresses review feedback on PR #803:
- Remove duplicate 'from argparse import ArgumentParser' across 12 files
- Move 'from __future__ import annotations' to line 1 in all files
- Clean up excessive blank lines
This commit is contained in:
RaccoonLabs 2026-04-16 05:59:04 -03:00 committed by GitHub
parent e64b0dbb2b
commit b881fb528e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 125 additions and 61 deletions

View file

@ -1,3 +1,6 @@
from __future__ import annotations
from typing import Any
from . metrics import SubscriberMetrics
from . subscriber import Subscriber
@ -5,11 +8,11 @@ from . spec import Spec
class SubscriberSpec(Spec):
def __init__(self, name, schema):
def __init__(self, name: str, schema: Any) -> None:
self.name = name
self.schema = schema
def add(self, flow, processor, definition):
def add(self, flow: Any, processor: Any, definition: dict[str, Any]) -> None:
subscriber_metrics = SubscriberMetrics(
processor = flow.id, flow = flow.name, name = self.name
@ -27,4 +30,3 @@ class SubscriberSpec(Spec):
# Put it in the consumer map, does that work?
# It means it gets start/stop call.
flow.consumer[self.name] = subscriber