diff --git a/docs/conf.py b/docs/conf.py index 199db8df..52e9fe3b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -77,8 +77,6 @@ def create_constraints_inventory() -> None: "qrules.topology.NodeType": "typing.TypeVar", "SpinFormalism": ("obj", "qrules.transition.SpinFormalism"), "StateDefinition": ("obj", "qrules.combinatorics.StateDefinition"), - "TypeAlias": "typing.TypeAlias", - "typing_extensions.TypeAlias": "typing.TypeAlias", } api_target_types: dict[str, str | tuple[str, str]] = { "qrules.combinatorics.InitialFacts": "obj", @@ -109,7 +107,6 @@ def create_constraints_inventory() -> None: "qrules.solving.GraphElementProperties": "obj", "qrules.solving.GraphSettings": "obj", "qrules.transition.StateTransition": "obj", - "typing.TypeAlias": "obj", } author = "Common Partial Wave Analysis" autodoc_default_options = { diff --git a/pyproject.toml b/pyproject.toml index c85dff69..6208ca13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ "particle", "python-constraint", "tqdm >=4.24.0", # autonotebook - 'typing-extensions; python_version <"3.10.0"', # Literal, Protocol, TypeAlias + 'typing-extensions; python_version <"3.8.0"', # Literal, Protocol ] description = "Rule-based particle reaction problem solver on a quantum number level" dynamic = ["version"] diff --git a/src/qrules/combinatorics.py b/src/qrules/combinatorics.py index e0f2a77c..8d79c49b 100644 --- a/src/qrules/combinatorics.py +++ b/src/qrules/combinatorics.py @@ -8,7 +8,6 @@ from __future__ import annotations import itertools -import sys from collections import OrderedDict from copy import deepcopy from typing import ( @@ -22,21 +21,18 @@ Union, ) +from qrules.particle import ParticleWithSpin from qrules.quantum_numbers import InteractionProperties, arange from qrules.topology import MutableTransition, Topology, get_originating_node_list if TYPE_CHECKING: - from qrules.particle import ParticleCollection, ParticleWithSpin + from qrules.particle import ParticleCollection -if sys.version_info >= (3, 10): - from typing import TypeAlias -else: - from typing_extensions import TypeAlias StateWithSpins = Tuple[str, Sequence[float]] StateDefinition = Union[str, StateWithSpins] """Particle name, optionally with a list of spin projections.""" -InitialFacts: TypeAlias = "MutableTransition[ParticleWithSpin, InteractionProperties]" +InitialFacts = MutableTransition[ParticleWithSpin, InteractionProperties] """A `.Transition` with only initial and final state information.""" diff --git a/src/qrules/solving.py b/src/qrules/solving.py index 3859fc9c..f42314a4 100644 --- a/src/qrules/solving.py +++ b/src/qrules/solving.py @@ -10,7 +10,6 @@ import inspect import logging -import sys from abc import ABC, abstractmethod from collections import defaultdict from copy import copy @@ -37,11 +36,6 @@ ) from qrules.topology import MutableTransition, Topology -if sys.version_info >= (3, 10): - from typing import TypeAlias -else: - from typing_extensions import TypeAlias - _LOGGER = logging.getLogger(__name__) @@ -76,11 +70,9 @@ class NodeSettings: interaction_strength: float = 1.0 -GraphSettings: TypeAlias = "MutableTransition[EdgeSettings, NodeSettings]" +GraphSettings = MutableTransition[EdgeSettings, NodeSettings] """(Mutable) mapping of settings on a `.Topology`.""" -GraphElementProperties: TypeAlias = ( - "MutableTransition[GraphEdgePropertyMap, GraphNodePropertyMap]" -) +GraphElementProperties = MutableTransition[GraphEdgePropertyMap, GraphNodePropertyMap] """(Mutable) mapping of edge and node properties on a `.Topology`.""" @@ -103,9 +95,7 @@ def topology(self) -> Topology: return self.initial_facts.topology -QuantumNumberSolution: TypeAlias = ( - "MutableTransition[GraphEdgePropertyMap, GraphNodePropertyMap]" -) +QuantumNumberSolution = MutableTransition[GraphEdgePropertyMap, GraphNodePropertyMap] def _convert_violated_rules_to_names( diff --git a/src/qrules/transition.py b/src/qrules/transition.py index 9eca9f67..1b2939c6 100644 --- a/src/qrules/transition.py +++ b/src/qrules/transition.py @@ -10,7 +10,7 @@ from copy import copy, deepcopy from enum import Enum, auto from multiprocessing import Pool -from typing import TYPE_CHECKING, Iterable, Sequence, overload +from typing import Iterable, Sequence, overload import attrs from attrs import define, field, frozen @@ -68,6 +68,7 @@ ) from qrules.topology import ( FrozenDict, + FrozenTransition, MutableTransition, Topology, create_isobar_topologies, @@ -79,12 +80,6 @@ else: from typing_extensions import Literal -if sys.version_info >= (3, 10): - from typing import TypeAlias -else: - from typing_extensions import TypeAlias -if TYPE_CHECKING: - from qrules.topology import FrozenTransition _LOGGER = logging.getLogger(__name__) @@ -741,7 +736,7 @@ class State: spin_projection: float = field(converter=_to_float) -StateTransition: TypeAlias = "FrozenTransition[State, InteractionProperties]" +StateTransition = FrozenTransition[State, InteractionProperties] """Transition of some initial `.State` to a final `.State`."""