diff --git a/.github/workflows/build_lint.yml b/.github/workflows/build_lint.yml index 79007d8b47f..4a8889eb8ca 100644 --- a/.github/workflows/build_lint.yml +++ b/.github/workflows/build_lint.yml @@ -35,8 +35,6 @@ jobs: include: - os: ubuntu python-version: "3.12" - - os: ubuntu - python-version: "3.11" # Disabled for now. See https://github.com/projectmesa/mesa/issues/1253 #- os: ubuntu # python-version: 'pypy-3.8' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 50b6d4a3714..03f7191b741 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: rev: v3.20.0 hooks: - id: pyupgrade - args: [--py311-plus] + args: [--py312-plus] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 # Use the ref you want to point at hooks: diff --git a/docs/tutorials/0_first_model.ipynb b/docs/tutorials/0_first_model.ipynb index cad5cbf217e..5848d1f9dbc 100644 --- a/docs/tutorials/0_first_model.ipynb +++ b/docs/tutorials/0_first_model.ipynb @@ -53,7 +53,7 @@ "source": [ "### Tutorial Setup\n", "\n", - "Create and activate a [virtual environment](http://docs.python-guide.org/en/latest/dev/virtualenvs/). *Python version 3.11 or higher is required*.\n", + "Create and activate a [virtual environment](http://docs.python-guide.org/en/latest/dev/virtualenvs/). *Python version 3.12 or higher is required*.\n", "\n", "Install Mesa:\n", "\n", diff --git a/mesa/discrete_space/cell_collection.py b/mesa/discrete_space/cell_collection.py index 834168b48a3..049fb0eed4d 100644 --- a/mesa/discrete_space/cell_collection.py +++ b/mesa/discrete_space/cell_collection.py @@ -20,7 +20,7 @@ from collections.abc import Callable, Iterable, Mapping from functools import cached_property from random import Random -from typing import TYPE_CHECKING, Generic, TypeVar +from typing import TYPE_CHECKING, TypeVar if TYPE_CHECKING: from mesa.discrete_space.cell import Cell @@ -29,7 +29,7 @@ T = TypeVar("T", bound="Cell") -class CellCollection(Generic[T]): +class CellCollection[T: Cell]: """An immutable collection of cells. Attributes: diff --git a/mesa/discrete_space/discrete_space.py b/mesa/discrete_space/discrete_space.py index f480ff15fbe..770a82938ac 100644 --- a/mesa/discrete_space/discrete_space.py +++ b/mesa/discrete_space/discrete_space.py @@ -18,7 +18,7 @@ import warnings from functools import cached_property from random import Random -from typing import Generic, TypeVar +from typing import TypeVar from mesa.agent import AgentSet from mesa.discrete_space.cell import Cell @@ -27,7 +27,7 @@ T = TypeVar("T", bound=Cell) -class DiscreteSpace(Generic[T]): +class DiscreteSpace[T: Cell]: """Base class for all discrete spaces. Attributes: diff --git a/mesa/discrete_space/grid.py b/mesa/discrete_space/grid.py index 5a99033f91f..7b0c5f5a586 100644 --- a/mesa/discrete_space/grid.py +++ b/mesa/discrete_space/grid.py @@ -17,7 +17,7 @@ from collections.abc import Sequence from itertools import product from random import Random -from typing import Any, Generic, TypeVar +from typing import Any, TypeVar from mesa.discrete_space import Cell, DiscreteSpace from mesa.discrete_space.property_layer import ( @@ -56,7 +56,7 @@ def unpickle_gridcell(parent, fields): return instance -class Grid(DiscreteSpace[T], Generic[T], HasPropertyLayers): +class Grid(DiscreteSpace[T], HasPropertyLayers): """Base class for all grid classes. Attributes: diff --git a/mesa/space.py b/mesa/space.py index d366db30337..c9cd04f4223 100644 --- a/mesa/space.py +++ b/mesa/space.py @@ -61,7 +61,7 @@ F = TypeVar("F", bound=Callable[..., Any]) -def accept_tuple_argument(wrapped_function: F) -> F: +def accept_tuple_argument[F: Callable[..., Any]](wrapped_function: F) -> F: """Decorator to allow grid methods that take a list of (x, y) coord tuples to also handle a single position. Tuples are wrapped in a single-item list rather than forcing user to do it. diff --git a/pyproject.toml b/pyproject.toml index e5e8a74ae30..159302d2910 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" name = "Mesa" description = "Agent-based modeling (ABM) in Python" license = { text = "Apache 2.0" } -requires-python = ">=3.11" +requires-python = ">=3.12" authors = [ { name = "Project Mesa Team", email = "maintainers@projectmesa.dev" }, ] @@ -25,7 +25,6 @@ classifiers = [ "Topic :: Scientific/Engineering :: Artificial Intelligence", "Intended Audience :: Science/Research", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "License :: OSI Approved :: Apache Software License", @@ -98,9 +97,9 @@ path = "mesa/__init__.py" [tool.ruff] # See https://github.com/charliermarsh/ruff#rules for error code definitions. -# Hardcode to Python 3.11. +# Hardcode to Python 3.12. # Reminder to update mesa-examples if the value below is changed. -target-version = "py311" +target-version = "py312" extend-exclude = ["build"] [tool.ruff.lint]