Update black.

Required for the new syntax in Python 3.12.
This commit is contained in:
Dan Albert 2023-11-30 21:02:27 -08:00
parent 28954d05eb
commit 2447cc156d
37 changed files with 7 additions and 45 deletions

View File

@ -11,7 +11,7 @@ jobs:
- uses: actions/setup-python@v2 - uses: actions/setup-python@v2
- uses: psf/black@stable - uses: psf/black@stable
with: with:
version: ~=22.12 version: ~=23.11
src: "." src: "."
options: "--check" options: "--check"

View File

@ -1,6 +1,6 @@
repos: repos:
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 22.12.0 rev: 23.11.0
hooks: hooks:
- id: black - id: black
language_version: python3 language_version: python3

View File

@ -65,7 +65,6 @@ class RecoveryTankerFlightPlan(StandardFlightPlan[RecoveryTankerLayout]):
class Builder(IBuilder[RecoveryTankerFlightPlan, RecoveryTankerLayout]): class Builder(IBuilder[RecoveryTankerFlightPlan, RecoveryTankerLayout]):
def layout(self) -> RecoveryTankerLayout: def layout(self) -> RecoveryTankerLayout:
builder = WaypointBuilder(self.flight, self.coalition) builder = WaypointBuilder(self.flight, self.coalition)
# TODO: Propagate the ship position to the Tanker's TOT, # TODO: Propagate the ship position to the Tanker's TOT,

View File

@ -29,7 +29,6 @@ class DefaultSquadronAssigner:
self.coalition.player self.coalition.player
): ):
for squadron_config in self.config.by_location[control_point]: for squadron_config in self.config.by_location[control_point]:
squadron_def = self.override_squadron_defaults( squadron_def = self.override_squadron_defaults(
self.find_squadron_for(squadron_config, control_point), self.find_squadron_for(squadron_config, control_point),
squadron_config, squadron_config,
@ -162,7 +161,6 @@ class DefaultSquadronAssigner:
def override_squadron_defaults( def override_squadron_defaults(
squadron_def: Optional[SquadronDef], config: SquadronConfig squadron_def: Optional[SquadronDef], config: SquadronConfig
) -> Optional[SquadronDef]: ) -> Optional[SquadronDef]:
if squadron_def is None: if squadron_def is None:
return None return None

View File

@ -119,7 +119,6 @@ class RequirementBuilder:
def maximum_turn_to( def maximum_turn_to(
self, turn_point: Point, next_point: Point, turn_limit: Heading self, turn_point: Point, next_point: Point, turn_limit: Heading
) -> None: ) -> None:
large_distance = nautical_miles(400) large_distance = nautical_miles(400)
next_heading = Heading.from_degrees( next_heading = Heading.from_degrees(
angle_between_points(next_point, turn_point) angle_between_points(next_point, turn_point)

View File

@ -89,7 +89,6 @@ class GroundPlanner:
self.reserve: List[CombatGroup] = [] self.reserve: List[CombatGroup] = []
def plan_groundwar(self) -> None: def plan_groundwar(self) -> None:
ground_unit_limit = self.cp.frontline_unit_count_limit ground_unit_limit = self.cp.frontline_unit_count_limit
remaining_available_frontline_units = ground_unit_limit remaining_available_frontline_units = ground_unit_limit
@ -139,7 +138,6 @@ class GroundPlanner:
remaining_available_frontline_units -= available remaining_available_frontline_units -= available
while available > 0: while available > 0:
if role == CombatGroupRole.SHORAD: if role == CombatGroupRole.SHORAD:
count = 1 count = 1
else: else:

View File

@ -241,7 +241,6 @@ class AntiAirLayout(TgoLayout):
location: PresetLocation, location: PresetLocation,
control_point: ControlPoint, control_point: ControlPoint,
) -> IadsGroundObject: ) -> IadsGroundObject:
if GroupTask.EARLY_WARNING_RADAR in self.tasks: if GroupTask.EARLY_WARNING_RADAR in self.tasks:
return EwrGroundObject(name, location, control_point) return EwrGroundObject(name, location, control_point)
elif any(tasking in self.tasks for tasking in GroupRole.AIR_DEFENSE.tasks): elif any(tasking in self.tasks for tasking in GroupRole.AIR_DEFENSE.tasks):

View File

@ -132,7 +132,6 @@ class LayoutLoader:
temp_mis.country(country.name).ship_group, temp_mis.country(country.name).ship_group,
temp_mis.country(country.name).static_group, temp_mis.country(country.name).static_group,
): ):
try: try:
g_id, u_id, group_name, group_mapping = mapping.group_for_name( g_id, u_id, group_name, group_mapping = mapping.group_for_name(
dcs_group.name dcs_group.name

View File

@ -8,7 +8,6 @@ from .pydcswaypointbuilder import PydcsWaypointBuilder
class RecoveryTankerBuilder(PydcsWaypointBuilder): class RecoveryTankerBuilder(PydcsWaypointBuilder):
def add_tasks(self, waypoint: MovingPoint) -> None: def add_tasks(self, waypoint: MovingPoint) -> None:
assert self.flight.flight_type == FlightType.REFUELING assert self.flight.flight_type == FlightType.REFUELING
# Tanker task required in conjunction with RecoveryTanker task. # Tanker task required in conjunction with RecoveryTanker task.
@ -48,7 +47,6 @@ class RecoveryTankerBuilder(PydcsWaypointBuilder):
) )
def configure_tanker_tacan(self, waypoint: MovingPoint) -> None: def configure_tanker_tacan(self, waypoint: MovingPoint) -> None:
if self.flight.unit_type.dcs_unit_type.tacan: if self.flight.unit_type.dcs_unit_type.tacan:
tanker_info = self.mission_data.tankers[-1] tanker_info = self.mission_data.tankers[-1]
tacan = tanker_info.tacan tacan = tanker_info.tacan

View File

@ -6,7 +6,6 @@ from .pydcswaypointbuilder import PydcsWaypointBuilder
class SplitPointBuilder(PydcsWaypointBuilder): class SplitPointBuilder(PydcsWaypointBuilder):
def add_tasks(self, waypoint: MovingPoint) -> None: def add_tasks(self, waypoint: MovingPoint) -> None:
if not self.flight.flight_type.is_air_to_air: if not self.flight.flight_type.is_air_to_air:
# Capture any non A/A type to avoid issues with SPJs that use the primary radar such as the F/A-18C. # Capture any non A/A type to avoid issues with SPJs that use the primary radar such as the F/A-18C.
# You can bully them with STT to not be able to fire radar guided missiles at you, # You can bully them with STT to not be able to fire radar guided missiles at you,

View File

@ -59,7 +59,6 @@ class DrawingsGenerator:
if destination in seen: if destination in seen:
continue continue
else: else:
# Determine path color # Determine path color
if cp.captured and destination.captured: if cp.captured and destination.captured:
color = BLUE_PATH_COLOR color = BLUE_PATH_COLOR

View File

@ -191,7 +191,6 @@ class FlotGenerator:
side: Country, side: Country,
forward_heading: Heading, forward_heading: Heading,
) -> None: ) -> None:
infantry_position = self.conflict.find_ground_position( infantry_position = self.conflict.find_ground_position(
group.points[0].position.random_point_within(250, 50), group.points[0].position.random_point_within(250, 50),
500, 500,
@ -304,7 +303,6 @@ class FlotGenerator:
# Artillery will fall back when under attack # Artillery will fall back when under attack
if stance != CombatStance.RETREAT: if stance != CombatStance.RETREAT:
# Hold position # Hold position
dcs_group.points[1].tasks.append(Hold()) dcs_group.points[1].tasks.append(Hold())
retreat = self.find_retreat_point( retreat = self.find_retreat_point(
@ -476,7 +474,6 @@ class FlotGenerator:
from_cp: ControlPoint, from_cp: ControlPoint,
to_cp: ControlPoint, to_cp: ControlPoint,
) -> None: ) -> None:
if not self.game.settings.perf_moving_units: if not self.game.settings.perf_moving_units:
return return

View File

@ -185,7 +185,6 @@ class NumberedWaypoint:
class FlightPlanBuilder: class FlightPlanBuilder:
WAYPOINT_DESC_MAX_LEN = 25 WAYPOINT_DESC_MAX_LEN = 25
def __init__(self, start_time: datetime.datetime, units: UnitSystem) -> None: def __init__(self, start_time: datetime.datetime, units: UnitSystem) -> None:
@ -503,7 +502,6 @@ class SupportPage(KneeboardPage):
aewc_ladder = [] aewc_ladder = []
for single_aewc in self.awacs: for single_aewc in self.awacs:
if single_aewc.depature_location is None: if single_aewc.depature_location is None:
dep = "-" dep = "-"
arr = "-" arr = "-"

View File

@ -402,7 +402,6 @@ class GenericCarrierGenerator(GroundObjectGenerator):
self.mission_data = mission_data self.mission_data = mission_data
def generate(self) -> None: def generate(self) -> None:
# This can also be refactored as the general generation was updated # This can also be refactored as the general generation was updated
atc = self.radio_registry.alloc_uhf() atc = self.radio_registry.alloc_uhf()

View File

@ -41,7 +41,6 @@ class ProcurementAi:
manage_front_line: bool, manage_front_line: bool,
manage_aircraft: bool, manage_aircraft: bool,
) -> None: ) -> None:
self.game = game self.game = game
self.is_player = for_player self.is_player = for_player
self.air_wing = game.air_wing_for(for_player) self.air_wing = game.air_wing_for(for_player)

View File

@ -47,7 +47,6 @@ class GameUpdateEventsJs(BaseModel):
def from_events( def from_events(
cls, events: GameUpdateEvents, game: Game | None cls, events: GameUpdateEvents, game: Game | None
) -> GameUpdateEventsJs: ) -> GameUpdateEventsJs:
# We still need to be able to send update events when there is no game loaded # We still need to be able to send update events when there is no game loaded
# because we need to send the unload event. # because we need to send the unload event.
new_combats = [] new_combats = []

View File

@ -245,7 +245,6 @@ class MissionResultsProcessor:
delta = DEFEAT_INFLUENCE delta = DEFEAT_INFLUENCE
status_msg = f"Enemy casualties outnumber allied casualties along the {cp.name}-{enemy_cp.name} frontline. Allied forces claim a victory." status_msg = f"Enemy casualties outnumber allied casualties along the {cp.name}-{enemy_cp.name} frontline. Allied forces claim a victory."
elif ally_casualties > enemy_casualties: elif ally_casualties > enemy_casualties:
if ( if (
ally_units_alive > 2 * enemy_units_alive ally_units_alive > 2 * enemy_units_alive
and player_aggresive and player_aggresive

View File

@ -54,7 +54,6 @@ class SquadronDef:
@classmethod @classmethod
def from_yaml(cls, path: Path) -> SquadronDef: def from_yaml(cls, path: Path) -> SquadronDef:
with path.open(encoding="utf8") as squadron_file: with path.open(encoding="utf8") as squadron_file:
data = yaml.safe_load(squadron_file) data = yaml.safe_load(squadron_file)

View File

@ -196,7 +196,8 @@ class TheaterGroup:
def max_threat_range(self, radar_only: bool = False) -> Distance: def max_threat_range(self, radar_only: bool = False) -> Distance:
"""Calculate the maximum threat range of the TheaterGroup. """Calculate the maximum threat range of the TheaterGroup.
This also checks for Launcher and Tracker Pairs and if they are functioning or not. Allows to also use only radar emitting units for the calculation with the parameter.""" This also checks for Launcher and Tracker Pairs and if they are functioning or not. Allows to also use only radar emitting units for the calculation with the parameter.
"""
max_non_radar = meters(0) max_non_radar = meters(0)
max_telar_range = meters(0) max_telar_range = meters(0)
max_tel_range = meters(0) max_tel_range = meters(0)

View File

@ -718,7 +718,6 @@ class PendingTransfers:
self.order_airlift_assets_at(control_point) self.order_airlift_assets_at(control_point)
def desired_airlift_capacity(self, control_point: ControlPoint) -> int: def desired_airlift_capacity(self, control_point: ControlPoint) -> int:
if control_point.has_factory: if control_point.has_factory:
is_major_hub = control_point.total_aircraft_parking > 0 is_major_hub = control_point.total_aircraft_parking > 0
# Check if there is a CP which is only reachable via Airlift # Check if there is a CP which is only reachable via Airlift

View File

@ -190,7 +190,6 @@ class Weather(ABC):
def interpolate_solar_activity( def interpolate_solar_activity(
time_of_day: TimeOfDay, high: float, low: float time_of_day: TimeOfDay, high: float, low: float
) -> float: ) -> float:
scale: float = 0 scale: float = 0
match time_of_day: match time_of_day:

View File

@ -32,7 +32,7 @@ def init():
if os.path.isfile(THEME_PREFERENCES_FILE_PATH): if os.path.isfile(THEME_PREFERENCES_FILE_PATH):
try: try:
with (open(THEME_PREFERENCES_FILE_PATH)) as prefs: with open(THEME_PREFERENCES_FILE_PATH) as prefs:
pref_data = json.loads(prefs.read()) pref_data = json.loads(prefs.read())
__theme_index = pref_data["theme_index"] __theme_index = pref_data["theme_index"]
set_theme_index(__theme_index) set_theme_index(__theme_index)
@ -83,5 +83,5 @@ def get_theme_css_file():
# save current theme index to json file # save current theme index to json file
def save_theme_config(): def save_theme_config():
pref_data = {"theme_index": get_theme_index()} pref_data = {"theme_index": get_theme_index()}
with (open(THEME_PREFERENCES_FILE_PATH, "w")) as prefs: with open(THEME_PREFERENCES_FILE_PATH, "w") as prefs:
prefs.write(json.dumps(pref_data)) prefs.write(json.dumps(pref_data))

View File

@ -54,7 +54,6 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
return waypoints return waypoints
def find_possible_waypoints(self): def find_possible_waypoints(self):
self.wpts = [] self.wpts = []
model = QStandardItemModel() model = QStandardItemModel()
i = 0 i = 0

View File

@ -9,7 +9,6 @@ from game.debriefing import Debriefing
class GameUpdateSignal(QObject): class GameUpdateSignal(QObject):
instance = None instance = None
gameupdated = Signal(Game) gameupdated = Signal(Game)
budgetupdated = Signal(Game) budgetupdated = Signal(Game)

View File

@ -28,7 +28,6 @@ from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
class DebriefingFileWrittenSignal(QObject): class DebriefingFileWrittenSignal(QObject):
instance = None instance = None
debriefingReceived = Signal(Debriefing) debriefingReceived = Signal(Debriefing)

View File

@ -70,7 +70,6 @@ class QGroundObjectMenu(QDialog):
self.init_ui() self.init_ui()
def init_ui(self): def init_ui(self):
self.mainLayout = QVBoxLayout() self.mainLayout = QVBoxLayout()
self.budget = QBudgetBox(self.game) self.budget = QBudgetBox(self.game)
self.budget.setGame(self.game) self.budget.setGame(self.game)
@ -105,7 +104,6 @@ class QGroundObjectMenu(QDialog):
self.setLayout(self.mainLayout) self.setLayout(self.mainLayout)
def doLayout(self): def doLayout(self):
self.update_total_value() self.update_total_value()
self.intelBox = QGroupBox("Units :") self.intelBox = QGroupBox("Units :")
self.intelLayout = QGridLayout() self.intelLayout = QGridLayout()

View File

@ -160,7 +160,6 @@ class IntelWindow(QDialog):
self.refresh_layout() self.refresh_layout()
def refresh_layout(self) -> None: def refresh_layout(self) -> None:
# Clear the existing layout # Clear the existing layout
if self.layout(): if self.layout():
idx = 0 idx = 0

View File

@ -14,7 +14,6 @@ class QFlightWaypointInfoBox(QGroupBox):
self.init_ui() self.init_ui()
def init_ui(self) -> None: def init_ui(self) -> None:
layout = QVBoxLayout() layout = QVBoxLayout()
x_pos_layout = QHBoxLayout() x_pos_layout = QHBoxLayout()

View File

@ -60,7 +60,6 @@ class QFlightWaypointTab(QFrame):
self.recreate_buttons.clear() self.recreate_buttons.clear()
for task in self.package.target.mission_types(for_player=True): for task in self.package.target.mission_types(for_player=True):
if ( if (
task == FlightType.AIR_ASSAULT task == FlightType.AIR_ASSAULT
and not self.game.lua_plugin_manager.is_plugin_enabled("ctld") and not self.game.lua_plugin_manager.is_plugin_enabled("ctld")

View File

@ -27,7 +27,6 @@ PREDEFINED_WAYPOINT_CATEGORIES = [
class QPredefinedWaypointSelectionWindow(QDialog): class QPredefinedWaypointSelectionWindow(QDialog):
# List of FlightWaypoint # List of FlightWaypoint
waypoints_added = Signal(list) waypoints_added = Signal(list)

View File

@ -87,7 +87,6 @@ class QLiberationPreferences(QFrame):
self.edit_dcs_install_dir.setText(install_dir) self.edit_dcs_install_dir.setText(install_dir)
def apply(self): def apply(self):
print("Applying changes") print("Applying changes")
self.saved_game_dir = self.edit_saved_game_dir.text() self.saved_game_dir = self.edit_saved_game_dir.text()
self.dcs_install_dir = self.edit_dcs_install_dir.text() self.dcs_install_dir = self.edit_dcs_install_dir.text()

View File

@ -345,7 +345,6 @@ class QSettingsWindow(QDialog):
self.setLayout(self.layout) self.setLayout(self.layout)
def initCheatLayout(self): def initCheatLayout(self):
self.cheatPage = QWidget() self.cheatPage = QWidget()
self.cheatLayout = QVBoxLayout() self.cheatLayout = QVBoxLayout()
self.cheatPage.setLayout(self.cheatLayout) self.cheatPage.setLayout(self.cheatLayout)

View File

@ -18,7 +18,6 @@ class QAircraftChart(QFrame):
self.setLayout(self.layout) self.setLayout(self.layout)
def generateUnitCharts(self): def generateUnitCharts(self):
self.alliedAircraft = [ self.alliedAircraft = [
d.allied_units.aircraft_count for d in self.game.game_stats.data_per_turn d.allied_units.aircraft_count for d in self.game.game_stats.data_per_turn
] ]

View File

@ -18,7 +18,6 @@ class QArmorChart(QFrame):
self.setLayout(self.layout) self.setLayout(self.layout)
def generateUnitCharts(self): def generateUnitCharts(self):
self.alliedArmor = [ self.alliedArmor = [
d.allied_units.vehicles_count for d in self.game.game_stats.data_per_turn d.allied_units.vehicles_count for d in self.game.game_stats.data_per_turn
] ]

View File

@ -3,7 +3,7 @@ annotated-types==0.6.0
anyio==3.7.1 anyio==3.7.1
asgiref==3.7.2 asgiref==3.7.2
attrs==23.1.0 attrs==23.1.0
black==22.12.0 black==23.11.0
certifi==2023.11.17 certifi==2023.11.17
cfgv==3.4.0 cfgv==3.4.0
click==8.1.7 click==8.1.7

View File

@ -21,7 +21,6 @@ def mock_registry() -> MockRegistry:
def test_lasercode_code(registry: ILaserCodeRegistry) -> None: def test_lasercode_code(registry: ILaserCodeRegistry) -> None:
assert LaserCode(1688, registry).code == 1688 assert LaserCode(1688, registry).code == 1688
# 1113 doesn't comply to the rules, but is the only code valid for FC3 aircraft like # 1113 doesn't comply to the rules, but is the only code valid for FC3 aircraft like

View File

@ -99,7 +99,6 @@ class TestFactionLoader(unittest.TestCase):
@pytest.mark.skip(reason="Faction unit names in the json files are outdated") @pytest.mark.skip(reason="Faction unit names in the json files are outdated")
def test_load_valid_faction_with_invalid_country(self) -> None: def test_load_valid_faction_with_invalid_country(self) -> None:
with (RESOURCES_DIR / "invalid_faction_country.json").open("r") as data: with (RESOURCES_DIR / "invalid_faction_country.json").open("r") as data:
try: try:
Faction.from_dict(json.load(data)) Faction.from_dict(json.load(data))