Fix missing argument exception

This commit is contained in:
Raffson 2023-10-02 17:50:55 +02:00
parent 227134d9c1
commit 226a171550
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 9 additions and 7 deletions

View File

@ -143,7 +143,7 @@ class QFlightCreator(QDialog):
def reject(self) -> None: def reject(self) -> None:
super().reject() super().reject()
# Clear the roster to return pilots to the pool. # Clear the roster to return pilots to the pool.
self.roster_editor.replace(None) self.roster_editor.replace(None, None)
def set_custom_name_text(self, text: str): def set_custom_name_text(self, text: str):
self.custom_name_text = text self.custom_name_text = text
@ -230,7 +230,7 @@ class QFlightCreator(QDialog):
self.update_max_size(self.squadron_selector.aircraft_available) self.update_max_size(self.squadron_selector.aircraft_available)
# Clear the roster first so we return the pilots to the pool. This way if we end # Clear the roster first so we return the pilots to the pool. This way if we end
# up repopulating from the same squadron we'll get the same pilots back. # up repopulating from the same squadron we'll get the same pilots back.
self.roster_editor.replace(None) self.roster_editor.replace(None, None)
if squadron is not None: if squadron is not None:
self.roster_editor.replace( self.roster_editor.replace(
squadron, FlightRoster(squadron, self.flight_size_spinner.value()) squadron, FlightRoster(squadron, self.flight_size_spinner.value())

View File

@ -1,5 +1,5 @@
import logging import logging
from typing import Optional, Callable, Union from typing import Optional, Callable
from PySide2.QtCore import Signal, QModelIndex from PySide2.QtCore import Signal, QModelIndex
from PySide2.QtWidgets import ( from PySide2.QtWidgets import (
@ -26,7 +26,7 @@ class PilotSelector(QComboBox):
available_pilots_changed = Signal() available_pilots_changed = Signal()
def __init__( def __init__(
self, squadron: Union[Squadron, None], roster: Optional[IFlightRoster], idx: int self, squadron: Optional[Squadron], roster: Optional[IFlightRoster], idx: int
) -> None: ) -> None:
super().__init__() super().__init__()
self.squadron = squadron self.squadron = squadron
@ -84,7 +84,7 @@ class PilotSelector(QComboBox):
self.roster.set_pilot(self.pilot_index, pilot) self.roster.set_pilot(self.pilot_index, pilot)
self.available_pilots_changed.emit() self.available_pilots_changed.emit()
def replace(self, squadron: Squadron, new_roster: Optional[FlightRoster]) -> None: def replace(self, squadron: Optional[Squadron], new_roster: Optional[FlightRoster]) -> None:
self.squadron = squadron self.squadron = squadron
self.roster = new_roster self.roster = new_roster
self.rebuild() self.rebuild()
@ -159,7 +159,7 @@ class PilotControls(QHBoxLayout):
finally: finally:
self.player_checkbox.blockSignals(False) self.player_checkbox.blockSignals(False)
def replace(self, squadron: Squadron, new_roster: Optional[FlightRoster]) -> None: def replace(self, squadron: Optional[Squadron], new_roster: Optional[FlightRoster]) -> None:
self.roster = new_roster self.roster = new_roster
if self.roster is None or self.pilot_index >= self.roster.max_size: if self.roster is None or self.pilot_index >= self.roster.max_size:
self.disable_and_clear() self.disable_and_clear()
@ -209,7 +209,9 @@ class FlightRosterEditor(QVBoxLayout):
for controls in self.pilot_controls[new_size:]: for controls in self.pilot_controls[new_size:]:
controls.disable_and_clear() controls.disable_and_clear()
def replace(self, squadron: Squadron, new_roster: Optional[FlightRoster]) -> None: def replace(
self, squadron: Optional[Squadron], new_roster: Optional[FlightRoster]
) -> None:
if self.roster is not None: if self.roster is not None:
self.roster.clear() self.roster.clear()
self.roster = new_roster self.roster = new_roster