Skip to content

Commit 7b00e44

Browse files
[pre-commit.ci] pre-commit autoupdate (#2751)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.9 → v0.11.8](astral-sh/ruff-pre-commit@v0.9.9...v0.11.8) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tom Pike <[email protected]>
1 parent 89db768 commit 7b00e44

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44
repos:
55
- repo: https://github.com/astral-sh/ruff-pre-commit
66
# Ruff version.
7-
rev: v0.9.9
7+
rev: v0.11.8
88
hooks:
99
# Run the linter.
1010
- id: ruff

mesa/agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def __init__(self, agents: Iterable[Agent], random: Random | None = None):
185185
Random()
186186
) # FIXME see issue 1981, how to get the central rng from model
187187
self.random = random
188-
self._agents = weakref.WeakKeyDictionary({agent: None for agent in agents})
188+
self._agents = weakref.WeakKeyDictionary(dict.fromkeys(agents))
189189

190190
def __len__(self) -> int:
191191
"""Return the number of agents in the AgentSet."""
@@ -264,7 +264,7 @@ def shuffle(self, inplace: bool = False) -> AgentSet:
264264
self.random.shuffle(weakrefs)
265265

266266
if inplace:
267-
self._agents.data = {entry: None for entry in weakrefs}
267+
self._agents.data = dict.fromkeys(weakrefs)
268268
return self
269269
else:
270270
return AgentSet(
@@ -303,7 +303,7 @@ def _update(self, agents: Iterable[Agent]):
303303
304304
This is a private method primarily used internally by other methods like select, shuffle, and sort.
305305
"""
306-
self._agents = weakref.WeakKeyDictionary({agent: None for agent in agents})
306+
self._agents = weakref.WeakKeyDictionary(dict.fromkeys(agents))
307307
return self
308308

309309
def do(self, method: str | Callable, *args, **kwargs) -> AgentSet:

0 commit comments

Comments
 (0)