Fix mypy issues in all modules except qt_ui.

This commit is contained in:
Dan Albert
2020-10-03 14:58:44 -07:00
parent 1808e5bccf
commit db6b660270
88 changed files with 1990 additions and 661 deletions

View File

@@ -3,7 +3,7 @@ from __future__ import annotations
import logging
import operator
from dataclasses import dataclass
from typing import Dict, Iterator, List, Optional, Set, TYPE_CHECKING, Tuple
from typing import Iterator, List, Optional, Set, TYPE_CHECKING, Tuple
from dcs.unittype import UnitType
@@ -406,17 +406,18 @@ class CoalitionMissionPlanner:
self.game.aircraft_inventory,
self.is_player
)
for flight in mission.flights:
if not builder.plan_flight(flight):
for proposed_flight in mission.flights:
if not builder.plan_flight(proposed_flight):
builder.release_planned_aircraft()
self.message("Insufficient aircraft",
f"Not enough aircraft in range for {mission}")
return
package = builder.build()
builder = FlightPlanBuilder(self.game, package, self.is_player)
flight_plan_builder = FlightPlanBuilder(self.game, package,
self.is_player)
for flight in package.flights:
builder.populate_flight_plan(flight)
flight_plan_builder.populate_flight_plan(flight)
self.ato.add_package(package)
def message(self, title, text) -> None:

View File

@@ -1,5 +1,78 @@
from dcs.planes import *
from dcs.helicopters import *
from dcs.helicopters import (
AH_1W,
AH_64A,
AH_64D,
Ka_50,
Mi_24V,
Mi_28N,
Mi_8MT,
OH_58D,
SA342L,
SA342M,
UH_1H,
)
from dcs.planes import (
AJS37,
AV8BNA,
A_10A,
A_10C,
A_10C_2,
A_20G,
B_17G,
Bf_109K_4,
C_101CC,
FA_18C_hornet,
FW_190A8,
FW_190D9,
F_14B,
F_15C,
F_15E,
F_16A,
F_16C_50,
F_4E,
F_5E_3,
F_86F_Sabre,
F_A_18C,
JF_17,
J_11A,
Ju_88A4,
L_39ZA,
MQ_9_Reaper,
M_2000C,
MiG_15bis,
MiG_19P,
MiG_21Bis,
MiG_23MLD,
MiG_25PD,
MiG_27K,
MiG_29A,
MiG_29G,
MiG_29K,
MiG_29S,
MiG_31,
Mirage_2000_5,
P_47D_30,
P_47D_30bl1,
P_47D_40,
P_51D,
P_51D_30_NA,
RQ_1A_Predator,
SpitfireLFMkIX,
SpitfireLFMkIXCW,
Su_17M4,
Su_24M,
Su_24MR,
Su_25,
Su_25T,
Su_25TM,
Su_27,
Su_30,
Su_33,
Su_34,
Tornado_GR4,
Tornado_IDS,
WingLoong_I,
)
# Interceptor are the aircraft prioritized for interception tasks
# If none is available, the AI will use regular CAP-capable aircraft instead

View File

@@ -1,10 +1,10 @@
from enum import Enum
from typing import List
from typing import Dict, Optional
from game import db
from dcs.unittype import UnitType
from dcs.point import MovingPoint, PointAction
from theater.controlpoint import ControlPoint
from theater.controlpoint import ControlPoint, MissionTarget
class FlightType(Enum):
@@ -73,8 +73,8 @@ class FlightWaypoint:
self.alt_type = "BARO"
self.name = ""
self.description = ""
self.targets = []
self.targetGroup = None
self.targets: List[MissionTarget] = []
self.targetGroup: Optional[MissionTarget] = None
self.obj_name = ""
self.pretty_name = ""
self.category: PredefinedWaypointCategory = PredefinedWaypointCategory.NOT_PREDEFINED
@@ -110,15 +110,9 @@ class FlightWaypoint:
class Flight:
unit_type: UnitType = None
from_cp = None
points: List[FlightWaypoint] = []
flight_type: FlightType = None
count: int = 0
client_count: int = 0
targets = []
use_custom_loadout = False
loadout = {}
preset_loadout_name = ""
start_type = "Runway"
group = False # Contains DCS Mission group data after mission has been generated
@@ -126,14 +120,14 @@ class Flight:
# How long before this flight should take off
scheduled_in = 0
def __init__(self, unit_type: UnitType, count: int, from_cp, flight_type: FlightType):
def __init__(self, unit_type: UnitType, count: int, from_cp: ControlPoint, flight_type: FlightType):
self.unit_type = unit_type
self.count = count
self.from_cp = from_cp
self.flight_type = flight_type
self.points = []
self.targets = []
self.loadout = {}
self.points: List[FlightWaypoint] = []
self.targets: List[MissionTarget] = []
self.loadout: Dict[str, str] = {}
self.start_type = "Runway"
def __repr__(self):
@@ -143,10 +137,10 @@ class Flight:
# Test
if __name__ == '__main__':
from pydcs.dcs.planes import A_10C
from dcs.planes import A_10C
from theater import ControlPoint, Point, List
from_cp = ControlPoint(0, "AA", Point(0, 0), None, [], 0, 0)
from_cp = ControlPoint(0, "AA", Point(0, 0), Point(0, 0), [], 0, 0)
f = Flight(A_10C(), 4, from_cp, FlightType.CAS)
f.scheduled_in = 50
print(f)

View File

@@ -388,12 +388,14 @@ class FlightPlanBuilder:
def _join_point(self) -> Point:
ingress_point = self.package.ingress_point
assert ingress_point is not None
heading = self._heading_to_package_airfield(ingress_point)
return ingress_point.point_from_heading(heading,
-self.doctrine.join_distance)
def _split_point(self) -> Point:
egress_point = self.package.egress_point
assert egress_point is not None
heading = self._heading_to_package_airfield(egress_point)
return egress_point.point_from_heading(heading,
-self.doctrine.split_distance)

View File

@@ -153,14 +153,16 @@ class WaypointBuilder:
self._target_point(target, name, f"STRIKE [{location.name}]: {name}",
location)
# TODO: Seems fishy.
self.ingress_point.targetGroup = location
if self.ingress_point is not None:
self.ingress_point.targetGroup = location
def sead_point(self, target: Union[TheaterGroundObject, Unit], name: str,
location: MissionTarget) -> None:
self._target_point(target, name, f"STRIKE [{location.name}]: {name}",
location)
# TODO: Seems fishy.
self.ingress_point.targetGroup = location
if self.ingress_point is not None:
self.ingress_point.targetGroup = location
def strike_point(self, target: Union[TheaterGroundObject, Unit], name: str,
location: MissionTarget) -> None:
@@ -191,12 +193,14 @@ class WaypointBuilder:
def sead_area(self, target: MissionTarget) -> None:
self._target_area(f"SEAD on {target.name}", target)
# TODO: Seems fishy.
self.ingress_point.targetGroup = target
if self.ingress_point is not None:
self.ingress_point.targetGroup = target
def dead_area(self, target: MissionTarget) -> None:
self._target_area(f"DEAD on {target.name}", target)
# TODO: Seems fishy.
self.ingress_point.targetGroup = target
if self.ingress_point is not None:
self.ingress_point.targetGroup = target
def _target_area(self, name: str, location: MissionTarget) -> None:
if self.ingress_point is None: