Skip to content

Commit

Permalink
Apply ruff format .
Browse files Browse the repository at this point in the history
  • Loading branch information
rht committed Mar 24, 2024
1 parent 948dc92 commit df54bbe
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.0
rev: v0.3.4
hooks:
# Run the linter.
- id: ruff
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/WolfSheep/wolf_sheep.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def spawn_offspring(self):
offspring.move_to(self.cell)
self.model.schedule.add(offspring)

def feed(self):
...
def feed(self): ...

def die(self):
self.cell.remove_agent(self)
Expand Down
1 change: 1 addition & 0 deletions mesa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Core Objects: Model, and Agent.
"""

import datetime

import mesa.space as space
Expand Down
1 change: 1 addition & 0 deletions mesa/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Core Objects: Agent
"""

# Mypy; for the `|` operator purpose
# Remove this __future__ import once the oldest supported Python is 3.10
from __future__ import annotations
Expand Down
1 change: 1 addition & 0 deletions mesa/datacollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* The model has an agent list called agents
* For collecting agent-level variables, agents must have a unique_id
"""

import contextlib
import itertools
import types
Expand Down
3 changes: 1 addition & 2 deletions mesa/experimental/cell_space/discrete_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def __init__(
def cutoff_empties(self):
return 7.953 * len(self._cells) ** 0.384

def _connect_single_cell(self, cell: T):
...
def _connect_single_cell(self, cell: T): ...

@cached_property
def all_cells(self):
Expand Down
6 changes: 2 additions & 4 deletions mesa/experimental/cell_space/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ def _connect_cells(self) -> None:
else:
self._connect_cells_nd()

def _connect_cells_2d(self) -> None:
...
def _connect_cells_2d(self) -> None: ...

def _connect_cells_nd(self) -> None:
...
def _connect_cells_nd(self) -> None: ...

def _validate_parameters(self):
if not all(isinstance(dim, int) and dim > 0 for dim in self.dimensions):
Expand Down
1 change: 1 addition & 0 deletions mesa/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Core Objects: Model
"""

# Mypy; for the `|` operator purpose
# Remove this __future__ import once the oldest supported Python is 3.10
from __future__ import annotations
Expand Down
12 changes: 4 additions & 8 deletions mesa/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,12 @@ def build_empties(self) -> None:
self._empties_built = True

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

@overload
def __getitem__(
self, index: tuple[int | slice, int | slice]
) -> GridContent | list[GridContent]:
...
) -> GridContent | list[GridContent]: ...

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

def place_agent(self, agent: Agent, pos: Coordinate) -> None:
...
def place_agent(self, agent: Agent, pos: Coordinate) -> None: ...

def remove_agent(self, agent: Agent) -> None:
...
def remove_agent(self, agent: Agent) -> None: ...

def move_agent(self, agent: Agent, pos: Coordinate) -> None:
"""Move an agent from its current position to a new position.
Expand Down
1 change: 1 addition & 0 deletions tests/test_datacollector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test the DataCollector
"""

import unittest

from mesa import Agent, Model
Expand Down
1 change: 1 addition & 0 deletions tests/test_grid.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test the Grid objects.
"""

import random
import unittest
from unittest.mock import Mock, patch
Expand Down

0 comments on commit df54bbe

Please sign in to comment.