Skip to content
Snippets Groups Projects
Commit ea99fc59 authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Improve typing

parent 5c4192ef
Branches
No related tags found
1 merge request!441Improve typing
Pipeline #125330 passed
...@@ -19,6 +19,8 @@ from b_asic.operation import Operation ...@@ -19,6 +19,8 @@ from b_asic.operation import Operation
from b_asic.port import InputPort from b_asic.port import InputPort
if TYPE_CHECKING: if TYPE_CHECKING:
from qtpy.QtWidgets import QGraphicsTextItem
from b_asic.GUI.main_window import SFGMainWindow from b_asic.GUI.main_window import SFGMainWindow
...@@ -90,13 +92,13 @@ class DragButton(QPushButton): ...@@ -90,13 +92,13 @@ class DragButton(QPushButton):
"""Return the type name of the underlying operation.""" """Return the type name of the underlying operation."""
return self.operation.type_name() return self.operation.type_name()
def add_label(self, label: str) -> None: def add_label(self, label: "QGraphicsTextItem") -> None:
""" """
Add label to button. Add label to button.
Parameters Parameters
---------- ----------
label : src label : QGraphicsTextItem
The label to add. The label to add.
""" """
self.label = label self.label = label
......
...@@ -3,7 +3,7 @@ import re ...@@ -3,7 +3,7 @@ import re
from collections import Counter, defaultdict from collections import Counter, defaultdict
from functools import reduce from functools import reduce
from math import log2 from math import log2
from typing import Dict, Iterable, List, Optional, Tuple, TypeVar, Union from typing import Dict, Iterable, List, Literal, Optional, Tuple, TypeVar, Union
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import networkx as nx import networkx as nx
...@@ -864,7 +864,7 @@ class ProcessCollection: ...@@ -864,7 +864,7 @@ class ProcessCollection:
def split_on_execution_time( def split_on_execution_time(
self, self,
heuristic: str = "left_edge", heuristic: Literal["graph_color", "left_edge"] = "left_edge",
coloring_strategy: str = "saturation_largest_first", coloring_strategy: str = "saturation_largest_first",
) -> List["ProcessCollection"]: ) -> List["ProcessCollection"]:
""" """
......
...@@ -7,7 +7,7 @@ Contains the schedule class for scheduling operations in an SFG. ...@@ -7,7 +7,7 @@ Contains the schedule class for scheduling operations in an SFG.
import io import io
import sys import sys
from collections import defaultdict from collections import defaultdict
from typing import Dict, List, Optional, Sequence, Tuple, cast from typing import Dict, List, Literal, Optional, Sequence, Tuple, cast
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
...@@ -100,7 +100,7 @@ class Schedule: ...@@ -100,7 +100,7 @@ class Schedule:
sfg: SFG, sfg: SFG,
schedule_time: Optional[int] = None, schedule_time: Optional[int] = None,
cyclic: bool = False, cyclic: bool = False,
algorithm: str = "ASAP", algorithm: Literal["ASAP", "ALAP", "provided"] = "ASAP",
start_times: Optional[Dict[GraphID, int]] = None, start_times: Optional[Dict[GraphID, int]] = None,
laps: Optional[Dict[GraphID, int]] = None, laps: Optional[Dict[GraphID, int]] = None,
max_resources: Optional[Dict[TypeName, int]] = None, max_resources: Optional[Dict[TypeName, int]] = None,
......
...@@ -14,7 +14,7 @@ import webbrowser ...@@ -14,7 +14,7 @@ import webbrowser
from collections import defaultdict, deque from collections import defaultdict, deque
from copy import deepcopy from copy import deepcopy
from importlib.machinery import SourceFileLoader from importlib.machinery import SourceFileLoader
from typing import TYPE_CHECKING, Deque, List, Optional, cast from typing import TYPE_CHECKING, Deque, List, Optional, cast, overload
# Qt/qtpy # Qt/qtpy
import qtpy import qtpy
...@@ -1006,6 +1006,18 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow): ...@@ -1006,6 +1006,18 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
self.actionToggle_full_screen.setIcon(get_icon('full-screen-exit')) self.actionToggle_full_screen.setIcon(get_icon('full-screen-exit'))
@overload
def start_scheduler(schedule: Schedule) -> Schedule: ...
@overload
def start_scheduler(schedule: None) -> Optional[Schedule]: ...
@overload
def start_scheduler() -> Optional[Schedule]: ...
def start_scheduler(schedule: Optional[Schedule] = None) -> Optional[Schedule]: def start_scheduler(schedule: Optional[Schedule] = None) -> Optional[Schedule]:
""" """
Start scheduler GUI. Start scheduler GUI.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment