Skip to content

Commit e07e681

Browse files
committed
passing mypy
1 parent 2d9243f commit e07e681

File tree

37 files changed

+253
-213
lines changed

37 files changed

+253
-213
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v6.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
77
- id: check-yaml
88
- id: check-added-large-files
99

1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.4.4
11+
rev: v0.12.12
1212
hooks:
1313
- id: ruff
1414
args: [--fix, --exit-non-zero-on-fix]
1515
- id: ruff-format
1616

1717
- repo: https://github.com/pre-commit/mirrors-mypy
18-
rev: v1.10.0
18+
rev: v1.17.1
1919
hooks:
2020
- id: mypy
2121
additional_dependencies: [

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ docker compose up -d
7474
7575
```bash
7676
make down
77-
```
77+
```

agent-engine/src/agent_engine/cognition/reflection/counterfactual.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def generate_counterfactual(
3232
Takes a past episode and generates a formal counterfactual "what if"
3333
scenario by querying the agent's CausalModel using a precise event_id.
3434
"""
35-
# FIX: Cast the generic component to the specific MemoryComponent type
35+
# Cast the generic component to the specific MemoryComponent type
3636
mem_comp = cast(
3737
MemoryComponent, simulation_state.get_component(agent_id, MemoryComponent)
3838
)

agent-sim/docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ python -m agent_sim.infrastructure.database.init_db
2020

2121
# The database is now ready.
2222
echo "--- DB initialization complete. Starting worker..."
23-
exec "$@"
23+
exec "$@"

agent-sim/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ dependencies = [
4242
agentsim = "agent_sim.cli:app"
4343

4444
[tool.setuptools.packages.find]
45-
where = ["src"]
45+
where = ["src"]

agent-sim/tests/__init__.py

Whitespace-only changes.

docker/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ services:
1818
redis:
1919
image: redis:7-alpine
2020
ports:
21-
- "6379:6379"
21+
- "6379:6379"

docs/api/agent-core.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,31 @@ Pure data containers that define entity properties and state.
5252
```python
5353
class HealthComponent(Component):
5454
"""Manages agent health and damage tracking."""
55-
55+
5656
def __init__(self, max_health: int = 100):
5757
self.max_health = max_health
5858
self.current_health = max_health
5959
self.last_damage_tick = 0
6060
self.damage_history: List[int] = []
61-
61+
6262
@property
6363
def health_percentage(self) -> float:
6464
"""Current health as percentage of maximum."""
6565
return self.current_health / self.max_health
66-
66+
6767
@property
6868
def is_critical(self) -> bool:
6969
"""True if health is below 25% of maximum."""
7070
return self.health_percentage < 0.25
71-
71+
7272
def to_dict(self) -> Dict[str, Any]:
7373
return {
7474
"max_health": self.max_health,
7575
"current_health": self.current_health,
7676
"last_damage_tick": self.last_damage_tick,
7777
"damage_history": self.damage_history
7878
}
79-
79+
8080
def validate(self, entity_id: str) -> Tuple[bool, List[str]]:
8181
errors = []
8282
if self.current_health < 0:
@@ -141,19 +141,19 @@ The provider pattern bridges the gap between world-agnostic cognitive systems an
141141
```python
142142
class VitalityMetricsProvider(VitalityMetricsProviderInterface):
143143
"""Bridges health/energy systems with cognitive architecture."""
144-
144+
145145
def get_normalized_vitality_metrics(
146-
self,
147-
entity_id: str,
148-
components: Dict[Type[Component], Component],
146+
self,
147+
entity_id: str,
148+
components: Dict[Type[Component], Component],
149149
config: Dict[str, Any]
150150
) -> Dict[str, float]:
151151
health_comp = components.get(HealthComponent)
152152
energy_comp = components.get(EnergyComponent)
153-
153+
154154
if not health_comp or not energy_comp:
155155
return {"health_norm": 0.5, "energy_norm": 0.5, "fatigue_norm": 0.5}
156-
156+
157157
return {
158158
"health_norm": health_comp.current / health_comp.max_health,
159159
"energy_norm": energy_comp.current / energy_comp.max_energy,
@@ -214,38 +214,38 @@ The parent class for all simulation systems, providing event bus access and life
214214
```python
215215
class ExampleSystem(System):
216216
"""Example system demonstrating best practices."""
217-
217+
218218
def __init__(self, simulation_state, config, cognitive_scaffold):
219219
super().__init__(simulation_state, config, cognitive_scaffold)
220-
220+
221221
# Subscribe to relevant events
222222
if self.event_bus:
223223
self.event_bus.subscribe("target_event", self.handle_event)
224224
self.event_bus.subscribe("tick_completed", self.on_tick_complete)
225-
225+
226226
def handle_event(self, event_data: Dict[str, Any]) -> None:
227227
"""Process specific events with proper error handling."""
228228
try:
229229
entity_id = event_data.get("entity_id")
230230
if not entity_id:
231231
return
232-
232+
233233
# Process event logic here
234234
self._process_event_logic(entity_id, event_data)
235-
235+
236236
except Exception as e:
237237
print(f"Error handling event in {self.__class__.__name__}: {e}")
238-
238+
239239
async def update(self, current_tick: int) -> None:
240240
"""Main system update loop called each simulation tick."""
241241
# Periodic processing logic here
242242
entities = self.simulation_state.get_entities_with_components([
243243
RequiredComponent
244244
])
245-
245+
246246
for entity_id, components in entities.items():
247247
await self._process_entity(entity_id, components, current_tick)
248-
248+
249249
def _process_entity(self, entity_id: str, components: Dict, tick: int):
250250
"""Process individual entity - separate method for testing."""
251251
pass
@@ -268,12 +268,12 @@ class AgentConfig(BaseModel):
268268
max_health: int = Field(default=100, gt=0, description="Maximum health points")
269269
learning_rate: float = Field(default=0.01, gt=0, le=1, description="Learning rate for Q-learning")
270270
memory_capacity: int = Field(default=1000, gt=0, description="Size of agent memory buffer")
271-
271+
272272
class EnvironmentConfig(BaseModel):
273273
"""Configuration for world environment settings."""
274274
grid_size: tuple[int, int] = Field(default=(50, 50), description="World dimensions")
275275
resource_spawn_rate: float = Field(default=0.02, ge=0, le=1, description="Resource spawn probability per tick")
276-
276+
277277
class SimulationConfig(BaseModel):
278278
"""Top-level simulation configuration."""
279279
agent: AgentConfig = Field(default_factory=AgentConfig)
@@ -328,7 +328,7 @@ class GoodComponent(Component):
328328
self.max_health = max_health
329329
self.current_health = max_health # Just data storage
330330
self.damage_taken = 0
331-
331+
332332
# Properties for computed values are acceptable
333333
@property
334334
def is_alive(self) -> bool:
@@ -366,7 +366,7 @@ for entity_id, components in entities.items():
366366
```python
367367
class OptimizedComponent(Component):
368368
__slots__ = ['x', 'y', 'timestamp'] # Reduces memory overhead
369-
369+
370370
def __init__(self, x: int, y: int):
371371
self.x = x
372372
self.y = y
@@ -383,10 +383,10 @@ class OptimizedComponent(Component):
383383
# Efficient event handling
384384
def __init__(self, simulation_state, config, cognitive_scaffold):
385385
super().__init__(simulation_state, config, cognitive_scaffold)
386-
386+
387387
# Subscribe to specific, relevant events only
388388
if self.event_bus:
389389
self.event_bus.subscribe("agent_death", self.handle_death)
390390
self.event_bus.subscribe("resource_depleted", self.handle_depletion)
391391
# Avoid subscribing to "all_events" or overly broad categories
392-
```
392+
```

0 commit comments

Comments
 (0)