File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4141 from abses .core .types import HOW_TO_SELECT
4242
4343
44- class ActorsList (Generic [A ], AgentSet ):
44+ class ActorsList (AgentSet , Generic [A ]):
4545 """Extended agent set specifically designed for managing Actor collections.
4646
4747 ActorsList extends Mesa's AgentSet with ABSESpy-specific functionality, providing
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ # -*-coding:utf-8 -*-
3+ """Regression tests for ActorsList vs mesa AgentSet MRO.
4+
5+ mesa 3.5 added ``typing.Generic`` to ``AgentSet.__bases__``. If ``ActorsList``
6+ is declared as ``class ActorsList(Generic[A], AgentSet)`` Python cannot
7+ linearize the MRO and ``import abses`` fails. Keep ``AgentSet`` first to stay
8+ compatible across mesa 3.1–3.5+.
9+ """
10+
11+ from __future__ import annotations
12+
13+ import typing
14+
15+ from mesa .agent import AgentSet
16+
17+
18+ def test_actorslist_subclasses_agentset () -> None :
19+ """ActorsList must remain a real AgentSet subclass."""
20+ from abses .agents .sequences import ActorsList
21+
22+ assert issubclass (ActorsList , AgentSet )
23+
24+
25+ def test_actorslist_stays_generic () -> None :
26+ """Generic parameterization ``ActorsList[Actor]`` must still work."""
27+ from abses .agents .actor import Actor
28+ from abses .agents .sequences import ActorsList
29+
30+ parameterized = ActorsList [Actor ]
31+ assert typing .get_origin (parameterized ) is ActorsList
32+
33+
34+ def test_agentset_first_in_bases () -> None :
35+ """Guard against regressing to ``(Generic[A], AgentSet)`` base order."""
36+ from abses .agents .sequences import ActorsList
37+
38+ assert ActorsList .__bases__ [0 ] is AgentSet
You can’t perform that action at this time.
0 commit comments