Skip to content

Commit

Permalink
MAINT: remove TypeAlias
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Mar 3, 2024
1 parent 9640f1d commit 2ae83dc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 32 deletions.
3 changes: 0 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
10 changes: 3 additions & 7 deletions src/qrules/combinatorics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from __future__ import annotations

import itertools
import sys
from collections import OrderedDict
from copy import deepcopy
from typing import (
Expand All @@ -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

Check warning on line 29 in src/qrules/combinatorics.py

View check run for this annotation

Codecov / codecov/patch

src/qrules/combinatorics.py#L29

Added line #L29 was not covered by tests

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."""


Expand Down
16 changes: 3 additions & 13 deletions src/qrules/solving.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import inspect
import logging
import sys
from abc import ABC, abstractmethod
from collections import defaultdict
from copy import copy
Expand All @@ -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__)


Expand Down Expand Up @@ -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`."""


Expand All @@ -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(
Expand Down
11 changes: 3 additions & 8 deletions src/qrules/transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -68,6 +68,7 @@
)
from qrules.topology import (
FrozenDict,
FrozenTransition,
MutableTransition,
Topology,
create_isobar_topologies,
Expand All @@ -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__)

Expand Down Expand Up @@ -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`."""


Expand Down

0 comments on commit 2ae83dc

Please sign in to comment.