Skip to content

Commit 8dd6ba9

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent e131699 commit 8dd6ba9

File tree

8 files changed

+23
-9
lines changed

8 files changed

+23
-9
lines changed

mesa_llm/llm_agent.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
OrthogonalVonNeumannGrid,
55
)
66
from mesa.model import Model
7+
78
try:
89
from mesa.space import (
910
ContinuousSpace,
@@ -14,6 +15,7 @@
1415
# Handle Mesa 4.0.dev0 locations or mock if missing
1516
from mesa.discrete_space.grid import Grid as MultiGrid
1617
from mesa.discrete_space.grid import Grid as SingleGrid
18+
1719
try:
1820
from mesa.experimental.continuous_space.continuous_space import ContinuousSpace
1921
except ImportError:

mesa_llm/parallel_stepping.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def step_agents_parallel_sync(agents: list[Agent | LLMAgent]) -> None:
8585
_original_shuffle_do = AgentSet.shuffle_do
8686
try:
8787
from mesa.agentset import _HardKeyAgentSet
88+
8889
_original_hardkey_shuffle_do = _HardKeyAgentSet.shuffle_do
8990
except ImportError:
9091
_HardKeyAgentSet = None
@@ -98,7 +99,7 @@ def _enhanced_shuffle_do(self, method: str, *args, **kwargs):
9899
if hasattr(agent, "model") and getattr(agent.model, "parallel_stepping", False):
99100
step_agents_parallel_sync(list(self))
100101
return
101-
102+
102103
if _HardKeyAgentSet and isinstance(self, _HardKeyAgentSet):
103104
_original_hardkey_shuffle_do(self, method, *args, **kwargs)
104105
else:

mesa_llm/tools/inbuilt_tools.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
OrthogonalMooreGrid,
55
OrthogonalVonNeumannGrid,
66
)
7+
78
try:
89
from mesa.space import (
910
ContinuousSpace,
@@ -14,6 +15,7 @@
1415
# Handle Mesa 4.0.dev0 locations or mock if missing
1516
from mesa.discrete_space.grid import Grid as MultiGrid
1617
from mesa.discrete_space.grid import Grid as SingleGrid
18+
1719
try:
1820
from mesa.experimental.continuous_space.continuous_space import ContinuousSpace
1921
except ImportError:

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55
from litellm import Choices, Message, ModelResponse
66
from mesa.model import Model
7+
78
try:
89
from mesa.space import MultiGrid
910
except ImportError:

tests/test_llm_agent.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
import pytest
66
from mesa.discrete_space import OrthogonalMooreGrid
77
from mesa.model import Model
8+
89
try:
910
from mesa.space import ContinuousSpace, MultiGrid, SingleGrid
1011
except ImportError:
1112
from mesa.discrete_space.grid import Grid as MultiGrid
1213
from mesa.discrete_space.grid import Grid as SingleGrid
14+
1315
try:
1416
from mesa.experimental.continuous_space.continuous_space import ContinuousSpace
1517
except ImportError:

tests/test_parallel_stepping.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import pytest
44
from mesa.agent import Agent, AgentSet
5-
from mesa.model import Model
65
from mesa.experimental.meta_agents.meta_agent import MetaAgent
6+
from mesa.model import Model
77

88
from mesa_llm.parallel_stepping import (
99
disable_automatic_parallel_stepping,
@@ -100,6 +100,8 @@ async def wrapper():
100100
asyncio.run(wrapper())
101101
assert a1.counter == 1
102102
assert a2.counter == 1
103+
104+
103105
@pytest.fixture(autouse=True)
104106
def manage_parallel_stepping_patch():
105107
# Helper to clean up parallel stepping state if tests fail
@@ -109,6 +111,7 @@ def manage_parallel_stepping_patch():
109111

110112
# --- Meta Agent Parallel Conflict Tests ---
111113

114+
112115
class ConflictWorker(Agent):
113116
def __init__(self, model):
114117
super().__init__(model)
@@ -143,10 +146,10 @@ def test_meta_agent_parallel_conflict_fix():
143146
"""
144147
enable_automatic_parallel_stepping("asyncio")
145148
model = ConflictBusinessModel()
146-
149+
147150
# Run one step
148151
model.step()
149-
152+
150153
# Assert worker was only stepped once
151154
# If the fix failed, this would be 2
152155
assert model.worker.step_count == 1
@@ -156,25 +159,25 @@ def test_meta_agent_multithreaded_conflict_fix():
156159
"""Test same logic but with multithreaded mode."""
157160
disable_automatic_parallel_stepping()
158161
enable_automatic_parallel_stepping("threading")
159-
162+
160163
model = ConflictBusinessModel()
161164
model.step()
162-
165+
163166
assert model.worker.step_count == 1
164167

165168

166169
def test_agent_becomes_independent_again():
167170
"""Test that an agent removed from MetaAgent is stepped by scheduler again."""
168171
enable_automatic_parallel_stepping("asyncio")
169172
model = ConflictBusinessModel()
170-
173+
171174
# 1. Initially it's a component
172175
assert model.worker.is_component is True
173-
176+
174177
# 2. Remove it from manager
175178
model.manager.remove_constituting_agents({model.worker})
176179
assert model.worker.is_component is False
177-
180+
178181
# 3. Model step should now step the worker directly
179182
model.step()
180183
assert model.worker.step_count == 1

tests/test_reasoning/test_cot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pytest
77
from mesa.model import Model
8+
89
try:
910
from mesa.space import MultiGrid
1011
except ImportError:

tests/test_tools/test_inbuilt_tools.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
import pytest
66
from mesa.discrete_space import OrthogonalMooreGrid, OrthogonalVonNeumannGrid
7+
78
try:
89
from mesa.space import ContinuousSpace, MultiGrid, SingleGrid
910
except ImportError:
1011
from mesa.discrete_space.grid import Grid as MultiGrid
1112
from mesa.discrete_space.grid import Grid as SingleGrid
13+
1214
try:
1315
from mesa.experimental.continuous_space.continuous_space import ContinuousSpace
1416
except ImportError:

0 commit comments

Comments
 (0)