mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Revert use of ABC in FlightPlan.
Mypy can't handle ABC dataclasses: https://github.com/python/mypy/issues/5374
This commit is contained in:
parent
1944a172a3
commit
8fe805bc68
@ -10,7 +10,6 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import random
|
import random
|
||||||
from abc import ABC, abstractmethod
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
@ -76,7 +75,7 @@ class InvalidObjectiveLocation(PlanningError):
|
|||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class FlightPlan(ABC):
|
class FlightPlan:
|
||||||
package: Package
|
package: Package
|
||||||
flight: Flight
|
flight: Flight
|
||||||
|
|
||||||
@ -85,10 +84,9 @@ class FlightPlan(ABC):
|
|||||||
"""A list of all waypoints in the flight plan, in order."""
|
"""A list of all waypoints in the flight plan, in order."""
|
||||||
return list(self.iter_waypoints())
|
return list(self.iter_waypoints())
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
||||||
"""Iterates over all waypoints in the flight plan, in order."""
|
"""Iterates over all waypoints in the flight plan, in order."""
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
def edges(
|
def edges(
|
||||||
self, until: Optional[FlightWaypoint] = None
|
self, until: Optional[FlightWaypoint] = None
|
||||||
@ -153,7 +151,6 @@ class FlightPlan(ABC):
|
|||||||
return self.flight.unit_type.fuel_consumption.cruise
|
return self.flight.unit_type.fuel_consumption.cruise
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
|
||||||
def tot_waypoint(self) -> Optional[FlightWaypoint]:
|
def tot_waypoint(self) -> Optional[FlightWaypoint]:
|
||||||
"""The waypoint that is associated with the package TOT, or None.
|
"""The waypoint that is associated with the package TOT, or None.
|
||||||
|
|
||||||
@ -161,7 +158,7 @@ class FlightPlan(ABC):
|
|||||||
user-planned missions without any useful waypoints and flight plans that
|
user-planned missions without any useful waypoints and flight plans that
|
||||||
failed to generate. Nevertheless, we have to defend against it.
|
failed to generate. Nevertheless, we have to defend against it.
|
||||||
"""
|
"""
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tot(self) -> timedelta:
|
def tot(self) -> timedelta:
|
||||||
@ -239,13 +236,11 @@ class FlightPlan(ABC):
|
|||||||
a.position, b.position, self.speed_between_waypoints(a, b)
|
a.position, b.position, self.speed_between_waypoints(a, b)
|
||||||
)
|
)
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
def request_escort_at(self) -> Optional[FlightWaypoint]:
|
def request_escort_at(self) -> Optional[FlightWaypoint]:
|
||||||
return None
|
return None
|
||||||
@ -321,10 +316,9 @@ class FlightPlan(ABC):
|
|||||||
return timedelta(minutes=8)
|
return timedelta(minutes=8)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
|
||||||
def mission_departure_time(self) -> timedelta:
|
def mission_departure_time(self) -> timedelta:
|
||||||
"""The time that the mission is complete and the flight RTBs."""
|
"""The time that the mission is complete and the flight RTBs."""
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
@ -332,23 +326,19 @@ class LoiterFlightPlan(FlightPlan):
|
|||||||
hold: FlightWaypoint
|
hold: FlightWaypoint
|
||||||
hold_duration: timedelta
|
hold_duration: timedelta
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
|
||||||
def tot_waypoint(self) -> Optional[FlightWaypoint]:
|
def tot_waypoint(self) -> Optional[FlightWaypoint]:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
|
||||||
def push_time(self) -> timedelta:
|
def push_time(self) -> timedelta:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
||||||
if waypoint == self.hold:
|
if waypoint == self.hold:
|
||||||
@ -364,9 +354,8 @@ class LoiterFlightPlan(FlightPlan):
|
|||||||
return travel_time + self.hold_duration
|
return travel_time + self.hold_duration
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
|
||||||
def mission_departure_time(self) -> timedelta:
|
def mission_departure_time(self) -> timedelta:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
@ -374,23 +363,20 @@ class FormationFlightPlan(LoiterFlightPlan):
|
|||||||
join: FlightWaypoint
|
join: FlightWaypoint
|
||||||
split: FlightWaypoint
|
split: FlightWaypoint
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
|
||||||
def package_speed_waypoints(self) -> set[FlightWaypoint]:
|
def package_speed_waypoints(self) -> set[FlightWaypoint]:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def combat_speed_waypoints(self) -> set[FlightWaypoint]:
|
def combat_speed_waypoints(self) -> set[FlightWaypoint]:
|
||||||
return self.package_speed_waypoints
|
return self.package_speed_waypoints
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
|
||||||
def tot_waypoint(self) -> Optional[FlightWaypoint]:
|
def tot_waypoint(self) -> Optional[FlightWaypoint]:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
def request_escort_at(self) -> Optional[FlightWaypoint]:
|
def request_escort_at(self) -> Optional[FlightWaypoint]:
|
||||||
return self.join
|
return self.join
|
||||||
@ -429,14 +415,12 @@ class FormationFlightPlan(LoiterFlightPlan):
|
|||||||
return self._travel_time_to_waypoint(self.join)
|
return self._travel_time_to_waypoint(self.join)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
|
||||||
def join_time(self) -> timedelta:
|
def join_time(self) -> timedelta:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
|
||||||
def split_time(self) -> timedelta:
|
def split_time(self) -> timedelta:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
def tot_for_waypoint(self, waypoint: FlightWaypoint) -> Optional[timedelta]:
|
||||||
if waypoint == self.join:
|
if waypoint == self.join:
|
||||||
@ -498,9 +482,8 @@ class PatrollingFlightPlan(FlightPlan):
|
|||||||
return self.patrol_end_time
|
return self.patrol_end_time
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
|
||||||
...
|
raise NotImplementedError
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def package_speed_waypoints(self) -> Set[FlightWaypoint]:
|
def package_speed_waypoints(self) -> Set[FlightWaypoint]:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user