Skip to content

Commit 51b4e9a

Browse files
Update Ruff to 0.3.4; apply ruff format . (#2088)
* Update Ruff to 0.3.4; apply ruff format . * [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>
1 parent 4eef2be commit 51b4e9a

File tree

12 files changed

+17
-18
lines changed

12 files changed

+17
-18
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.2.0
7+
rev: v0.3.4
88
hooks:
99
# Run the linter.
1010
- id: ruff

benchmarks/WolfSheep/wolf_sheep.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ def spawn_offspring(self):
3838
offspring.move_to(self.cell)
3939
self.model.schedule.add(offspring)
4040

41-
def feed(self):
42-
...
41+
def feed(self): ...
4342

4443
def die(self):
4544
self.cell.remove_agent(self)

mesa/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
Core Objects: Model, and Agent.
55
"""
6+
67
import datetime
78

89
import mesa.space as space

mesa/agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
Core Objects: Agent
55
"""
6+
67
# Mypy; for the `|` operator purpose
78
# Remove this __future__ import once the oldest supported Python is 3.10
89
from __future__ import annotations

mesa/datacollection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* The model has an agent list called agents
3333
* For collecting agent-level variables, agents must have a unique_id
3434
"""
35+
3536
import contextlib
3637
import itertools
3738
import types

mesa/experimental/cell_space/discrete_space.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ def __init__(
4343
def cutoff_empties(self):
4444
return 7.953 * len(self._cells) ** 0.384
4545

46-
def _connect_single_cell(self, cell: T):
47-
...
46+
def _connect_single_cell(self, cell: T): ...
4847

4948
@cached_property
5049
def all_cells(self):

mesa/experimental/cell_space/grid.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,9 @@ def _connect_cells(self) -> None:
5151
else:
5252
self._connect_cells_nd()
5353

54-
def _connect_cells_2d(self) -> None:
55-
...
54+
def _connect_cells_2d(self) -> None: ...
5655

57-
def _connect_cells_nd(self) -> None:
58-
...
56+
def _connect_cells_nd(self) -> None: ...
5957

6058
def _validate_parameters(self):
6159
if not all(isinstance(dim, int) and dim > 0 for dim in self.dimensions):

mesa/model.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
Core Objects: Model
55
"""
6+
67
# Mypy; for the `|` operator purpose
78
# Remove this __future__ import once the oldest supported Python is 3.10
89
from __future__ import annotations
@@ -55,7 +56,7 @@ def __new__(cls, *args: Any, **kwargs: Any) -> Any:
5556
if obj._seed is None:
5657
# We explicitly specify the seed here so that we know its value in
5758
# advance.
58-
obj._seed = random.random() # noqa: S311
59+
obj._seed = random.random()
5960
obj.random = random.Random(obj._seed)
6061
# TODO: Remove these 2 lines just before Mesa 3.0
6162
obj._steps = 0

mesa/space.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,12 @@ def build_empties(self) -> None:
150150
self._empties_built = True
151151

152152
@overload
153-
def __getitem__(self, index: int | Sequence[Coordinate]) -> list[GridContent]:
154-
...
153+
def __getitem__(self, index: int | Sequence[Coordinate]) -> list[GridContent]: ...
155154

156155
@overload
157156
def __getitem__(
158157
self, index: tuple[int | slice, int | slice]
159-
) -> GridContent | list[GridContent]:
160-
...
158+
) -> GridContent | list[GridContent]: ...
161159

162160
def __getitem__(self, index):
163161
"""Access contents from the grid."""
@@ -420,11 +418,9 @@ def get_cell_list_contents(self, cell_list: Iterable[Coordinate]) -> list[Agent]
420418
"""
421419
return list(self.iter_cell_list_contents(cell_list))
422420

423-
def place_agent(self, agent: Agent, pos: Coordinate) -> None:
424-
...
421+
def place_agent(self, agent: Agent, pos: Coordinate) -> None: ...
425422

426-
def remove_agent(self, agent: Agent) -> None:
427-
...
423+
def remove_agent(self, agent: Agent) -> None: ...
428424

429425
def move_agent(self, agent: Agent, pos: Coordinate) -> None:
430426
"""Move an agent from its current position to a new position.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,5 @@ extend-ignore = [
132132
"S310", # Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected.
133133
"S603", # `subprocess` call: check for execution of untrusted input
134134
"ISC001", # ruff format asks to disable this feature
135+
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
135136
]

0 commit comments

Comments
 (0)