From f69d7b2ac73d7f44407aee1a616aefb5f4c1aaf7 Mon Sep 17 00:00:00 2001 From: Adam Amer <136176500+adamamer20@users.noreply.github.com> Date: Wed, 3 Jul 2024 10:27:50 +0200 Subject: [PATCH] from typing to typing-extensions --- mesa_frames/abstract/agents.py | 4 +++- mesa_frames/abstract/mixin.py | 3 ++- mesa_frames/concrete/agents.py | 8 ++++---- mesa_frames/concrete/agentset_pandas.py | 4 +++- mesa_frames/concrete/agentset_polars.py | 4 +++- mesa_frames/concrete/model.py | 4 +++- mesa_frames/types.py | 2 +- pyproject.toml | 1 + 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/mesa_frames/abstract/agents.py b/mesa_frames/abstract/agents.py index e82d877..4a90d3b 100644 --- a/mesa_frames/abstract/agents.py +++ b/mesa_frames/abstract/agents.py @@ -3,9 +3,11 @@ from abc import abstractmethod from collections.abc import Callable, Collection, Iterable, Iterator, Sequence from contextlib import suppress -from typing import TYPE_CHECKING, Any, Literal, Self, overload from numpy.random import Generator +from typing_extensions import Any, Self, overload + +from typing import TYPE_CHECKING, Literal from mesa_frames.abstract.mixin import CopyMixin from mesa_frames.types import BoolSeries, DataFrame, IdsLike, Index, MaskLike, Series diff --git a/mesa_frames/abstract/mixin.py b/mesa_frames/abstract/mixin.py index b027546..8d73b84 100644 --- a/mesa_frames/abstract/mixin.py +++ b/mesa_frames/abstract/mixin.py @@ -1,6 +1,7 @@ from abc import ABC, abstractmethod from copy import copy, deepcopy -from typing import Self + +from typing_extensions import Self class CopyMixin(ABC): diff --git a/mesa_frames/concrete/agents.py b/mesa_frames/concrete/agents.py index 6a4fa94..ed6a9fa 100644 --- a/mesa_frames/concrete/agents.py +++ b/mesa_frames/concrete/agents.py @@ -1,10 +1,10 @@ from collections import defaultdict -from collections.abc import Callable, Iterable, Iterator, Sequence -from typing import Any, Literal, Self, cast, overload - -from collections.abc import Collection +from collections.abc import Callable, Collection, Iterable, Iterator, Sequence import polars as pl +from typing_extensions import Any, Self, overload + +from typing import Literal, cast from mesa_frames.abstract.agents import AgentContainer, AgentSetDF from mesa_frames.types import DataFrame, IdsLike, MaskLike, Series diff --git a/mesa_frames/concrete/agentset_pandas.py b/mesa_frames/concrete/agentset_pandas.py index 74d275a..ee4542b 100644 --- a/mesa_frames/concrete/agentset_pandas.py +++ b/mesa_frames/concrete/agentset_pandas.py @@ -1,8 +1,10 @@ from collections.abc import Callable, Collection, Iterable, Iterator, Sequence -from typing import TYPE_CHECKING, Any, Self, overload import pandas as pd import polars as pl +from typing_extensions import Any, Self, overload + +from typing import TYPE_CHECKING from mesa_frames.abstract.agents import AgentSetDF from mesa_frames.concrete.agentset_polars import AgentSetPolars diff --git a/mesa_frames/concrete/agentset_polars.py b/mesa_frames/concrete/agentset_polars.py index df0f575..6646ece 100644 --- a/mesa_frames/concrete/agentset_polars.py +++ b/mesa_frames/concrete/agentset_polars.py @@ -1,8 +1,10 @@ from collections.abc import Callable, Collection, Iterable, Iterator, Sequence -from typing import TYPE_CHECKING, Any, Self, overload import polars as pl from polars.type_aliases import IntoExpr +from typing_extensions import Any, Self, overload + +from typing import TYPE_CHECKING from mesa_frames.concrete.agents import AgentSetDF from mesa_frames.types import PolarsIdsLike, PolarsMaskLike diff --git a/mesa_frames/concrete/model.py b/mesa_frames/concrete/model.py index c2c3964..c31d31a 100644 --- a/mesa_frames/concrete/model.py +++ b/mesa_frames/concrete/model.py @@ -1,7 +1,9 @@ from collections.abc import Sequence -from typing import TYPE_CHECKING, Any import numpy as np +from typing_extensions import Any + +from typing import TYPE_CHECKING from mesa_frames.concrete.agents import AgentsDF diff --git a/mesa_frames/types.py b/mesa_frames/types.py index a4c8e36..fcef6d6 100644 --- a/mesa_frames/types.py +++ b/mesa_frames/types.py @@ -1,9 +1,9 @@ from collections.abc import Collection, Hashable -from typing import Literal import pandas as pd import polars as pl from numpy import ndarray +from typing import Literal ####----- Agnostic Types -----#### AgnosticMask = Literal["all", "active"] | Hashable | None diff --git a/pyproject.toml b/pyproject.toml index 05ac9ad..b9d18f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ authors = [ license = { text = "MIT" } dependencies = [ "numpy~=1.26", + "typing-extensions>=4.9" ] [project.optional-dependencies]