Skip to content

Commit

Permalink
Reformat code with upgraded version of black
Browse files Browse the repository at this point in the history
  • Loading branch information
zhexu14 committed Oct 4, 2024
1 parent 49f98e7 commit eda29a3
Show file tree
Hide file tree
Showing 53 changed files with 115 additions and 156 deletions.
1 change: 1 addition & 0 deletions game/ato/closestairfields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Objective adjacency lists."""

from __future__ import annotations

from typing import Dict, Iterator, List, Optional, TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions game/ato/flightplans/flightplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
type, and the size of the flight. The FlightPlanBuilder is responsible for
generating the waypoints for the mission.
"""

from __future__ import annotations

import math
Expand Down
9 changes: 3 additions & 6 deletions game/ato/flightplans/formation.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class FormationLayout(LoiterLayout, ABC):
class FormationFlightPlan(LoiterFlightPlan[LayoutT], ABC):
@property
@abstractmethod
def package_speed_waypoints(self) -> set[FlightWaypoint]:
...
def package_speed_waypoints(self) -> set[FlightWaypoint]: ...

@property
def combat_speed_waypoints(self) -> set[FlightWaypoint]:
Expand Down Expand Up @@ -69,13 +68,11 @@ def travel_time_to_rendezvous(self) -> timedelta:

@property
@abstractmethod
def join_time(self) -> datetime:
...
def join_time(self) -> datetime: ...

@property
@abstractmethod
def split_time(self) -> datetime:
...
def split_time(self) -> datetime: ...

def tot_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.layout.join:
Expand Down
3 changes: 1 addition & 2 deletions game/ato/flightplans/ibuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def theater(self) -> ConflictTheater:
return self.flight.departure.theater

@abstractmethod
def build(self, dump_debug_info: bool = False) -> FlightPlanT:
...
def build(self, dump_debug_info: bool = False) -> FlightPlanT: ...

@property
def package(self) -> Package:
Expand Down
3 changes: 1 addition & 2 deletions game/ato/flightplans/loiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def hold_duration(self) -> timedelta:

@property
@abstractmethod
def push_time(self) -> datetime:
...
def push_time(self) -> datetime: ...

def depart_time_for_waypoint(self, waypoint: FlightWaypoint) -> datetime | None:
if waypoint == self.layout.hold:
Expand Down
3 changes: 1 addition & 2 deletions game/ato/flightplans/uizonedisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ class UiZone:

class UiZoneDisplay(abc.ABC):
@abc.abstractmethod
def ui_zone(self) -> UiZone:
...
def ui_zone(self) -> UiZone: ...
15 changes: 5 additions & 10 deletions game/ato/flightstate/flightstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ def alive(self) -> bool:

@property
@abstractmethod
def cancelable(self) -> bool:
...
def cancelable(self) -> bool: ...

@abstractmethod
def on_game_tick(
self, events: GameUpdateEvents, time: datetime, duration: timedelta
) -> None:
...
) -> None: ...

@property
def in_flight(self) -> bool:
Expand Down Expand Up @@ -95,17 +93,14 @@ def should_halt_sim(self) -> bool:

@property
@abstractmethod
def is_waiting_for_start(self) -> bool:
...
def is_waiting_for_start(self) -> bool: ...

@abstractmethod
def estimate_position(self) -> Point:
...
def estimate_position(self) -> Point: ...

@property
@abstractmethod
def spawn_type(self) -> StartType:
...
def spawn_type(self) -> StartType: ...

def a2a_commit_region(self) -> Optional[ThreatPoly]:
return None
Expand Down
9 changes: 3 additions & 6 deletions game/ato/flightstate/inflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,13 @@ def travel_time_between_waypoints(self) -> timedelta:
)

@abstractmethod
def estimate_position(self) -> Point:
...
def estimate_position(self) -> Point: ...

@abstractmethod
def estimate_altitude(self) -> tuple[Distance, str]:
...
def estimate_altitude(self) -> tuple[Distance, str]: ...

@abstractmethod
def estimate_speed(self) -> Speed:
...
def estimate_speed(self) -> Speed: ...

def estimate_fuel_at_current_waypoint(self) -> float:
initial_fuel = super().estimate_fuel()
Expand Down
18 changes: 6 additions & 12 deletions game/ato/iflightroster.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,20 @@

class IFlightRoster(ABC):
@abstractmethod
def iter_pilots(self) -> Iterator[Pilot | None]:
...
def iter_pilots(self) -> Iterator[Pilot | None]: ...

@abstractmethod
def pilot_at(self, idx: int) -> Pilot | None:
...
def pilot_at(self, idx: int) -> Pilot | None: ...

@property
@abstractmethod
def max_size(self) -> int:
...
def max_size(self) -> int: ...

@abstractmethod
def resize(self, new_size: int) -> None:
...
def resize(self, new_size: int) -> None: ...

@abstractmethod
def set_pilot(self, index: int, pilot: Optional[Pilot]) -> None:
...
def set_pilot(self, index: int, pilot: Optional[Pilot]) -> None: ...

@abstractmethod
def clear(self) -> None:
...
def clear(self) -> None: ...
1 change: 1 addition & 0 deletions game/callsigns.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for working with DCS group callsigns."""

import logging
import re
from typing import Any
Expand Down
6 changes: 2 additions & 4 deletions game/campaignloader/factionrecommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ def __init__(self, name: str) -> None:
self.name = name

@abstractmethod
def register_campaign_specific_faction(self, factions: Factions) -> None:
...
def register_campaign_specific_faction(self, factions: Factions) -> None: ...

@abstractmethod
def get_faction(self, factions: Factions) -> Faction:
...
def get_faction(self, factions: Factions) -> Faction: ...

@staticmethod
def from_field(
Expand Down
6 changes: 2 additions & 4 deletions game/commander/tasks/frontlinestancetask.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def __init__(self, front_line: FrontLine, player: bool) -> None:

@property
@abstractmethod
def stance(self) -> CombatStance:
...
def stance(self) -> CombatStance: ...

@staticmethod
def management_allowed(state: TheaterState) -> bool:
Expand All @@ -49,8 +48,7 @@ def better_stance_already_set(self, state: TheaterState) -> bool:

@property
@abstractmethod
def have_sufficient_front_line_advantage(self) -> bool:
...
def have_sufficient_front_line_advantage(self) -> bool: ...

@property
def ground_force_balance(self) -> float:
Expand Down
9 changes: 4 additions & 5 deletions game/commander/tasks/packageplanningtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def execute(self, coalition: Coalition) -> None:
coalition.ato.add_package(self.package)

@abstractmethod
def propose_flights(self) -> None:
...
def propose_flights(self) -> None: ...

def propose_flight(
self,
Expand Down Expand Up @@ -118,9 +117,9 @@ def iter_iads_ranges(
target_ranges: list[
tuple[Union[IadsGroundObject, NavalGroundObject], Distance]
] = []
all_iads: Iterator[
Union[IadsGroundObject, NavalGroundObject]
] = itertools.chain(state.enemy_air_defenses, state.enemy_ships)
all_iads: Iterator[Union[IadsGroundObject, NavalGroundObject]] = (
itertools.chain(state.enemy_air_defenses, state.enemy_ships)
)
for target in all_iads:
distance = meters(target.distance_to(self.target))
if range_type is RangeType.Detection:
Expand Down
3 changes: 1 addition & 2 deletions game/commander/tasks/theatercommandertask.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@

class TheaterCommanderTask(PrimitiveTask[TheaterState]):
@abstractmethod
def execute(self, coalition: Coalition) -> None:
...
def execute(self, coalition: Coalition) -> None: ...
1 change: 1 addition & 0 deletions game/commander/theatercommander.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
https://en.wikipedia.org/wiki/Hierarchical_task_network
"""

from __future__ import annotations

from datetime import datetime
Expand Down
6 changes: 3 additions & 3 deletions game/dcs/groundunittype.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class GroundUnitType(UnitType[Type[VehicleType]]):
reversed_heading: bool = False

_by_name: ClassVar[dict[str, GroundUnitType]] = {}
_by_unit_type: ClassVar[
dict[type[VehicleType], list[GroundUnitType]]
] = defaultdict(list)
_by_unit_type: ClassVar[dict[type[VehicleType], list[GroundUnitType]]] = (
defaultdict(list)
)

def __setstate__(self, state: dict[str, Any]) -> None:
# Update any existing models with new data on load.
Expand Down
6 changes: 2 additions & 4 deletions game/dcs/lasercodeconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ def from_yaml(data: dict[str, Any]) -> LaserCodeConfig:
)

@abstractmethod
def iter_prop_ids(self) -> Iterator[str]:
...
def iter_prop_ids(self) -> Iterator[str]: ...

@abstractmethod
def property_dict_for_code(self, code: int) -> dict[str, int]:
...
def property_dict_for_code(self, code: int) -> dict[str, int]: ...


class SinglePropertyLaserCodeConfig(LaserCodeConfig):
Expand Down
9 changes: 3 additions & 6 deletions game/flightplan/waypointactions/waypointaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@

class WaypointAction(ABC):
@abstractmethod
def describe(self) -> str:
...
def describe(self) -> str: ...

@abstractmethod
def update_state(
self, state: ActionState, time: datetime, duration: timedelta
) -> timedelta:
...
) -> timedelta: ...

@abstractmethod
def iter_tasks(self, ctx: TaskContext) -> Iterator[Task]:
...
def iter_tasks(self, ctx: TaskContext) -> Iterator[Task]: ...
6 changes: 2 additions & 4 deletions game/flightplan/waypointstrategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ def point_at_heading(p: Point, heading: Heading, distance: Distance) -> Point:

class Prerequisite(ABC):
@abstractmethod
def is_satisfied(self) -> bool:
...
def is_satisfied(self) -> bool: ...

@abstractmethod
def describe_debug_info(
self, to_geojson: Callable[[BaseGeometry], dict[str, Any]]
) -> dict[str, Any]:
...
) -> dict[str, Any]: ...


class DistancePrerequisite(Prerequisite):
Expand Down
14 changes: 6 additions & 8 deletions game/htn.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

class WorldState(ABC, Generic[WorldStateT]):
@abstractmethod
def clone(self) -> WorldStateT:
...
def clone(self) -> WorldStateT: ...


class Task(Generic[WorldStateT]):
Expand All @@ -24,18 +23,17 @@ class Task(Generic[WorldStateT]):

class PrimitiveTask(Task[WorldStateT], Generic[WorldStateT], ABC):
@abstractmethod
def preconditions_met(self, state: WorldStateT) -> bool:
...
def preconditions_met(self, state: WorldStateT) -> bool: ...

@abstractmethod
def apply_effects(self, state: WorldStateT) -> None:
...
def apply_effects(self, state: WorldStateT) -> None: ...


class CompoundTask(Task[WorldStateT], Generic[WorldStateT], ABC):
@abstractmethod
def each_valid_method(self, state: WorldStateT) -> Iterator[Method[WorldStateT]]:
...
def each_valid_method(
self, state: WorldStateT
) -> Iterator[Method[WorldStateT]]: ...


PrimitiveTaskT = TypeVar("PrimitiveTaskT", bound=PrimitiveTask[Any])
Expand Down
8 changes: 5 additions & 3 deletions game/infos/information.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ def __init__(self, title: str = "", text: str = "", turn: int = 0) -> None:

def __str__(self) -> str:
return "[{}][{}] {} {}".format(
self.timestamp.strftime("%Y-%m-%d %H:%M:%S")
if self.timestamp is not None
else "",
(
self.timestamp.strftime("%Y-%m-%d %H:%M:%S")
if self.timestamp is not None
else ""
),
self.turn,
self.title,
self.text,
Expand Down
6 changes: 2 additions & 4 deletions game/lasercodes/ilasercoderegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

class ILaserCodeRegistry(ABC):
@abstractmethod
def alloc_laser_code(self) -> LaserCode:
...
def alloc_laser_code(self) -> LaserCode: ...

@abstractmethod
def release_code(self, code: LaserCode) -> None:
...
def release_code(self, code: LaserCode) -> None: ...
1 change: 1 addition & 0 deletions game/logging_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Logging APIs."""

import logging
import logging.config
import os
Expand Down
1 change: 1 addition & 0 deletions game/missiongenerator/briefinggenerator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Briefing generation logic
"""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions game/missiongenerator/kneeboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
only be added per airframe, so PvP missions where each side have the same
aircraft will be able to see the enemy's kneeboard for the same airframe.
"""

import datetime
import math
import textwrap
Expand Down
1 change: 1 addition & 0 deletions game/missiongenerator/tgogenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
objectives is defined in the Theater by a TheaterGroundObject. These classes
create the pydcs groups and statics for those areas and add them to the mission.
"""

from __future__ import annotations

import logging
Expand Down
Loading

0 comments on commit eda29a3

Please sign in to comment.