Skip to content

Commit

Permalink
change typing declarations to be identical in overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Nov 27, 2023
1 parent b9c1c42 commit fac3d79
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions pacman/model/graphs/abstract_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def label(self) -> Optional[str]:

@property
@abstractmethod
def pre_vertex(self) -> V:
def pre_vertex(self) -> AbstractVertex:
"""
The vertex at the start of the edge.
Expand All @@ -49,7 +49,7 @@ def pre_vertex(self) -> V:

@property
@abstractmethod
def post_vertex(self) -> V:
def post_vertex(self) -> AbstractVertex:
"""
The vertex at the end of the edge.
Expand Down
2 changes: 1 addition & 1 deletion pacman/model/graphs/abstract_edge_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, identifier: str,
self._allowed_edge_types = allowed_edge_types
self._edges: OrderedSet[E] = OrderedSet()

def add_edge(self, edge: E):
def add_edge(self, edge: AbstractEdge):
"""
Add an edge to the edge partition.
Expand Down
7 changes: 3 additions & 4 deletions pacman/model/graphs/abstract_multiple_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
from pacman.exceptions import PacmanConfigurationException, PacmanValueError
from pacman.model.graphs import (
AbstractVertex, AbstractEdge, AbstractEdgePartition)
from pacman.model.graphs.abstract_edge_partition import E
#: :meta private:
V = TypeVar("V", bound=AbstractVertex)
#: :meta private:
E = TypeVar("E", bound=AbstractEdge)


class AbstractMultiplePartition(AbstractEdgePartition[E], Generic[V, E]):
Expand Down Expand Up @@ -53,7 +52,7 @@ def __init__(
"There were clones in your list of acceptable pre vertices")

@overrides(AbstractEdgePartition.add_edge)
def add_edge(self, edge: E):
def add_edge(self, edge: AbstractEdge):
# safety checks
if edge.pre_vertex not in self._pre_vertices.keys():
raise PacmanValueError(
Expand All @@ -67,5 +66,5 @@ def add_edge(self, edge: E):

@property
@overrides(AbstractEdgePartition.pre_vertices)
def pre_vertices(self) -> Collection[V]:
def pre_vertices(self) -> Collection[AbstractVertex]:
return self._pre_vertices.keys()
6 changes: 3 additions & 3 deletions pacman/model/graphs/abstract_single_source_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
from __future__ import annotations
from typing import (
Generic, Sequence, Tuple, Type, TypeVar, Union, TYPE_CHECKING)
Collection, Generic, Tuple, Type, TypeVar, Union, TYPE_CHECKING)
from spinn_utilities.abstract_base import AbstractBase
from spinn_utilities.overrides import overrides
from pacman.exceptions import PacmanConfigurationException
Expand Down Expand Up @@ -44,7 +44,7 @@ def __init__(
self._pre_vertex = pre_vertex

@overrides(AbstractEdgePartition.add_edge)
def add_edge(self, edge: E):
def add_edge(self, edge: AbstractEdge):
super().add_edge(edge)
if edge.pre_vertex != self._pre_vertex:
raise PacmanConfigurationException(
Expand All @@ -61,5 +61,5 @@ def pre_vertex(self) -> V:

@property
@overrides(AbstractEdgePartition.pre_vertices)
def pre_vertices(self) -> Sequence[V]:
def pre_vertices(self) -> Collection[AbstractVertex]:
return (self.pre_vertex, )
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, machine_vertex: V, label: Optional[str],
super().remember_machine_vertex(machine_vertex)

@overrides(ApplicationVertex.remember_machine_vertex)
def remember_machine_vertex(self, machine_vertex: V):
def remember_machine_vertex(self, machine_vertex: MachineVertex):
assert (machine_vertex == self._machine_vertex)

@property
Expand Down
2 changes: 1 addition & 1 deletion pacman/model/graphs/application/application_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def splitter(self, new_value: AbstractSplitterCommon[Self]):
self._splitter = new_value
self._splitter.set_governed_app_vertex(self)

def remember_machine_vertex(self, machine_vertex: MV):
def remember_machine_vertex(self, machine_vertex: MachineVertex):
"""
Adds the machine vertex to the iterable returned by machine_vertices
Expand Down
2 changes: 1 addition & 1 deletion pacman/model/graphs/common/mdslice.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __hash__(self) -> int:

@classmethod
@overrides(Slice.from_string, extend_doc=False)
def from_string(cls, as_str: str) -> Union[MDSlice, Slice]:
def from_string(cls, as_str: str) -> Slice:
"""
Convert the string form of a :py:class:`MDSlice` into an object
instance.
Expand Down
2 changes: 1 addition & 1 deletion pacman/model/graphs/machine/machine_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, pre_vertex: MachineVertex, post_vertex: MachineVertex,

@property
@overrides(AbstractEdge.label)
def label(self):
def label(self) -> Optional[str]:
return self._label

@property
Expand Down
3 changes: 2 additions & 1 deletion pacman/model/resources/constant_sdram.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional
from spinn_utilities.overrides import overrides
from .abstract_sdram import AbstractSDRAM

Expand All @@ -35,7 +36,7 @@ def __init__(self, sdram: int):
self._sdram = int(sdram)

@overrides(AbstractSDRAM.get_total_sdram)
def get_total_sdram(self, n_timesteps) -> int: # @UnusedVariable
def get_total_sdram(self, n_timesteps: Optional[int]) -> int: # @UnusedVariable
return self._sdram

@property
Expand Down

0 comments on commit fac3d79

Please sign in to comment.