From 2447cc156d0de40d978c4393f43b8fe783717d28 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 30 Nov 2023 21:02:27 -0800 Subject: [PATCH] Update black. Required for the new syntax in Python 3.12. --- .github/workflows/lint.yml | 2 +- .pre-commit-config.yaml | 2 +- game/ato/flightplans/shiprecoverytanker.py | 1 - game/campaignloader/defaultsquadronassigner.py | 2 -- game/flightplan/waypointstrategy.py | 1 - game/ground_forces/ai_ground_planner.py | 2 -- game/layout/layout.py | 1 - game/layout/layoutloader.py | 1 - game/missiongenerator/aircraft/waypoints/recoverytanker.py | 2 -- game/missiongenerator/aircraft/waypoints/splitpoint.py | 1 - game/missiongenerator/drawingsgenerator.py | 1 - game/missiongenerator/flotgenerator.py | 3 --- game/missiongenerator/kneeboard.py | 2 -- game/missiongenerator/tgogenerator.py | 1 - game/procurement.py | 1 - game/server/eventstream/models.py | 1 - game/sim/missionresultsprocessor.py | 1 - game/squadrons/squadrondef.py | 1 - game/theater/theatergroup.py | 3 ++- game/transfers.py | 1 - game/weather/weather.py | 1 - qt_ui/liberation_theme.py | 4 ++-- qt_ui/widgets/combos/QPredefinedWaypointSelectionComboBox.py | 1 - qt_ui/windows/GameUpdateSignal.py | 1 - qt_ui/windows/QWaitingForMissionResultWindow.py | 1 - qt_ui/windows/groundobject/QGroundObjectMenu.py | 2 -- qt_ui/windows/intel.py | 1 - .../mission/flight/waypoints/QFlightWaypointInfoBox.py | 1 - qt_ui/windows/mission/flight/waypoints/QFlightWaypointTab.py | 1 - .../flight/waypoints/QPredefinedWaypointSelectionWindow.py | 1 - qt_ui/windows/preferences/QLiberationPreferences.py | 1 - qt_ui/windows/settings/QSettingsWindow.py | 1 - qt_ui/windows/stats/QAircraftChart.py | 1 - qt_ui/windows/stats/QArmorChart.py | 1 - requirements.txt | 2 +- tests/lasercodes/test_lasercode.py | 1 - tests/test_factions.py | 1 - 37 files changed, 7 insertions(+), 45 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index af6462f2..557b9b42 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/setup-python@v2 - uses: psf/black@stable with: - version: ~=22.12 + version: ~=23.11 src: "." options: "--check" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a2305ad..428235a7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.11.0 hooks: - id: black language_version: python3 \ No newline at end of file diff --git a/game/ato/flightplans/shiprecoverytanker.py b/game/ato/flightplans/shiprecoverytanker.py index 22746989..54f734c1 100644 --- a/game/ato/flightplans/shiprecoverytanker.py +++ b/game/ato/flightplans/shiprecoverytanker.py @@ -65,7 +65,6 @@ class RecoveryTankerFlightPlan(StandardFlightPlan[RecoveryTankerLayout]): class Builder(IBuilder[RecoveryTankerFlightPlan, RecoveryTankerLayout]): def layout(self) -> RecoveryTankerLayout: - builder = WaypointBuilder(self.flight, self.coalition) # TODO: Propagate the ship position to the Tanker's TOT, diff --git a/game/campaignloader/defaultsquadronassigner.py b/game/campaignloader/defaultsquadronassigner.py index d2f70bc6..00e0cd73 100644 --- a/game/campaignloader/defaultsquadronassigner.py +++ b/game/campaignloader/defaultsquadronassigner.py @@ -29,7 +29,6 @@ class DefaultSquadronAssigner: self.coalition.player ): for squadron_config in self.config.by_location[control_point]: - squadron_def = self.override_squadron_defaults( self.find_squadron_for(squadron_config, control_point), squadron_config, @@ -162,7 +161,6 @@ class DefaultSquadronAssigner: def override_squadron_defaults( squadron_def: Optional[SquadronDef], config: SquadronConfig ) -> Optional[SquadronDef]: - if squadron_def is None: return None diff --git a/game/flightplan/waypointstrategy.py b/game/flightplan/waypointstrategy.py index d873488d..d91bf3f6 100644 --- a/game/flightplan/waypointstrategy.py +++ b/game/flightplan/waypointstrategy.py @@ -119,7 +119,6 @@ class RequirementBuilder: def maximum_turn_to( self, turn_point: Point, next_point: Point, turn_limit: Heading ) -> None: - large_distance = nautical_miles(400) next_heading = Heading.from_degrees( angle_between_points(next_point, turn_point) diff --git a/game/ground_forces/ai_ground_planner.py b/game/ground_forces/ai_ground_planner.py index 5514deb1..5a58671b 100644 --- a/game/ground_forces/ai_ground_planner.py +++ b/game/ground_forces/ai_ground_planner.py @@ -89,7 +89,6 @@ class GroundPlanner: self.reserve: List[CombatGroup] = [] def plan_groundwar(self) -> None: - ground_unit_limit = self.cp.frontline_unit_count_limit remaining_available_frontline_units = ground_unit_limit @@ -139,7 +138,6 @@ class GroundPlanner: remaining_available_frontline_units -= available while available > 0: - if role == CombatGroupRole.SHORAD: count = 1 else: diff --git a/game/layout/layout.py b/game/layout/layout.py index 38c0fac0..08fb1879 100644 --- a/game/layout/layout.py +++ b/game/layout/layout.py @@ -241,7 +241,6 @@ class AntiAirLayout(TgoLayout): location: PresetLocation, control_point: ControlPoint, ) -> IadsGroundObject: - if GroupTask.EARLY_WARNING_RADAR in self.tasks: return EwrGroundObject(name, location, control_point) elif any(tasking in self.tasks for tasking in GroupRole.AIR_DEFENSE.tasks): diff --git a/game/layout/layoutloader.py b/game/layout/layoutloader.py index 61a1c7a3..6e5d626e 100644 --- a/game/layout/layoutloader.py +++ b/game/layout/layoutloader.py @@ -132,7 +132,6 @@ class LayoutLoader: temp_mis.country(country.name).ship_group, temp_mis.country(country.name).static_group, ): - try: g_id, u_id, group_name, group_mapping = mapping.group_for_name( dcs_group.name diff --git a/game/missiongenerator/aircraft/waypoints/recoverytanker.py b/game/missiongenerator/aircraft/waypoints/recoverytanker.py index b15bd873..70ded28f 100644 --- a/game/missiongenerator/aircraft/waypoints/recoverytanker.py +++ b/game/missiongenerator/aircraft/waypoints/recoverytanker.py @@ -8,7 +8,6 @@ from .pydcswaypointbuilder import PydcsWaypointBuilder class RecoveryTankerBuilder(PydcsWaypointBuilder): def add_tasks(self, waypoint: MovingPoint) -> None: - assert self.flight.flight_type == FlightType.REFUELING # Tanker task required in conjunction with RecoveryTanker task. @@ -48,7 +47,6 @@ class RecoveryTankerBuilder(PydcsWaypointBuilder): ) def configure_tanker_tacan(self, waypoint: MovingPoint) -> None: - if self.flight.unit_type.dcs_unit_type.tacan: tanker_info = self.mission_data.tankers[-1] tacan = tanker_info.tacan diff --git a/game/missiongenerator/aircraft/waypoints/splitpoint.py b/game/missiongenerator/aircraft/waypoints/splitpoint.py index 82e06558..d99e8c71 100644 --- a/game/missiongenerator/aircraft/waypoints/splitpoint.py +++ b/game/missiongenerator/aircraft/waypoints/splitpoint.py @@ -6,7 +6,6 @@ from .pydcswaypointbuilder import PydcsWaypointBuilder class SplitPointBuilder(PydcsWaypointBuilder): def add_tasks(self, waypoint: MovingPoint) -> None: - 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. # You can bully them with STT to not be able to fire radar guided missiles at you, diff --git a/game/missiongenerator/drawingsgenerator.py b/game/missiongenerator/drawingsgenerator.py index 808ed09e..19a2f235 100644 --- a/game/missiongenerator/drawingsgenerator.py +++ b/game/missiongenerator/drawingsgenerator.py @@ -59,7 +59,6 @@ class DrawingsGenerator: if destination in seen: continue else: - # Determine path color if cp.captured and destination.captured: color = BLUE_PATH_COLOR diff --git a/game/missiongenerator/flotgenerator.py b/game/missiongenerator/flotgenerator.py index 0f84283f..3be5fc4c 100644 --- a/game/missiongenerator/flotgenerator.py +++ b/game/missiongenerator/flotgenerator.py @@ -191,7 +191,6 @@ class FlotGenerator: side: Country, forward_heading: Heading, ) -> None: - infantry_position = self.conflict.find_ground_position( group.points[0].position.random_point_within(250, 50), 500, @@ -304,7 +303,6 @@ class FlotGenerator: # Artillery will fall back when under attack if stance != CombatStance.RETREAT: - # Hold position dcs_group.points[1].tasks.append(Hold()) retreat = self.find_retreat_point( @@ -476,7 +474,6 @@ class FlotGenerator: from_cp: ControlPoint, to_cp: ControlPoint, ) -> None: - if not self.game.settings.perf_moving_units: return diff --git a/game/missiongenerator/kneeboard.py b/game/missiongenerator/kneeboard.py index 5f65b8a7..b9de7d64 100644 --- a/game/missiongenerator/kneeboard.py +++ b/game/missiongenerator/kneeboard.py @@ -185,7 +185,6 @@ class NumberedWaypoint: class FlightPlanBuilder: - WAYPOINT_DESC_MAX_LEN = 25 def __init__(self, start_time: datetime.datetime, units: UnitSystem) -> None: @@ -503,7 +502,6 @@ class SupportPage(KneeboardPage): aewc_ladder = [] for single_aewc in self.awacs: - if single_aewc.depature_location is None: dep = "-" arr = "-" diff --git a/game/missiongenerator/tgogenerator.py b/game/missiongenerator/tgogenerator.py index b3866555..414e1778 100644 --- a/game/missiongenerator/tgogenerator.py +++ b/game/missiongenerator/tgogenerator.py @@ -402,7 +402,6 @@ class GenericCarrierGenerator(GroundObjectGenerator): self.mission_data = mission_data def generate(self) -> None: - # This can also be refactored as the general generation was updated atc = self.radio_registry.alloc_uhf() diff --git a/game/procurement.py b/game/procurement.py index 08ced19a..cb39c545 100644 --- a/game/procurement.py +++ b/game/procurement.py @@ -41,7 +41,6 @@ class ProcurementAi: manage_front_line: bool, manage_aircraft: bool, ) -> None: - self.game = game self.is_player = for_player self.air_wing = game.air_wing_for(for_player) diff --git a/game/server/eventstream/models.py b/game/server/eventstream/models.py index f8aeb893..d1496b9a 100644 --- a/game/server/eventstream/models.py +++ b/game/server/eventstream/models.py @@ -47,7 +47,6 @@ class GameUpdateEventsJs(BaseModel): def from_events( cls, events: GameUpdateEvents, game: Game | None ) -> GameUpdateEventsJs: - # We still need to be able to send update events when there is no game loaded # because we need to send the unload event. new_combats = [] diff --git a/game/sim/missionresultsprocessor.py b/game/sim/missionresultsprocessor.py index 7410781c..882a52c4 100644 --- a/game/sim/missionresultsprocessor.py +++ b/game/sim/missionresultsprocessor.py @@ -245,7 +245,6 @@ class MissionResultsProcessor: delta = DEFEAT_INFLUENCE 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: - if ( ally_units_alive > 2 * enemy_units_alive and player_aggresive diff --git a/game/squadrons/squadrondef.py b/game/squadrons/squadrondef.py index 1c009dab..22d5b99b 100644 --- a/game/squadrons/squadrondef.py +++ b/game/squadrons/squadrondef.py @@ -54,7 +54,6 @@ class SquadronDef: @classmethod def from_yaml(cls, path: Path) -> SquadronDef: - with path.open(encoding="utf8") as squadron_file: data = yaml.safe_load(squadron_file) diff --git a/game/theater/theatergroup.py b/game/theater/theatergroup.py index 7ffd71da..247e7ba2 100644 --- a/game/theater/theatergroup.py +++ b/game/theater/theatergroup.py @@ -196,7 +196,8 @@ class TheaterGroup: def max_threat_range(self, radar_only: bool = False) -> Distance: """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_telar_range = meters(0) max_tel_range = meters(0) diff --git a/game/transfers.py b/game/transfers.py index 86f946d4..8f8b92be 100644 --- a/game/transfers.py +++ b/game/transfers.py @@ -718,7 +718,6 @@ class PendingTransfers: self.order_airlift_assets_at(control_point) def desired_airlift_capacity(self, control_point: ControlPoint) -> int: - if control_point.has_factory: is_major_hub = control_point.total_aircraft_parking > 0 # Check if there is a CP which is only reachable via Airlift diff --git a/game/weather/weather.py b/game/weather/weather.py index 0f5d2b25..0573766d 100644 --- a/game/weather/weather.py +++ b/game/weather/weather.py @@ -190,7 +190,6 @@ class Weather(ABC): def interpolate_solar_activity( time_of_day: TimeOfDay, high: float, low: float ) -> float: - scale: float = 0 match time_of_day: diff --git a/qt_ui/liberation_theme.py b/qt_ui/liberation_theme.py index 0bc7dbb3..25eb26a4 100644 --- a/qt_ui/liberation_theme.py +++ b/qt_ui/liberation_theme.py @@ -32,7 +32,7 @@ def init(): if os.path.isfile(THEME_PREFERENCES_FILE_PATH): try: - with (open(THEME_PREFERENCES_FILE_PATH)) as prefs: + with open(THEME_PREFERENCES_FILE_PATH) as prefs: pref_data = json.loads(prefs.read()) __theme_index = pref_data["theme_index"] set_theme_index(__theme_index) @@ -83,5 +83,5 @@ def get_theme_css_file(): # save current theme index to json file def save_theme_config(): 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)) diff --git a/qt_ui/widgets/combos/QPredefinedWaypointSelectionComboBox.py b/qt_ui/widgets/combos/QPredefinedWaypointSelectionComboBox.py index bf7ab100..2d0955a6 100644 --- a/qt_ui/widgets/combos/QPredefinedWaypointSelectionComboBox.py +++ b/qt_ui/widgets/combos/QPredefinedWaypointSelectionComboBox.py @@ -54,7 +54,6 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox): return waypoints def find_possible_waypoints(self): - self.wpts = [] model = QStandardItemModel() i = 0 diff --git a/qt_ui/windows/GameUpdateSignal.py b/qt_ui/windows/GameUpdateSignal.py index fe6721e6..b3fe1262 100644 --- a/qt_ui/windows/GameUpdateSignal.py +++ b/qt_ui/windows/GameUpdateSignal.py @@ -9,7 +9,6 @@ from game.debriefing import Debriefing class GameUpdateSignal(QObject): - instance = None gameupdated = Signal(Game) budgetupdated = Signal(Game) diff --git a/qt_ui/windows/QWaitingForMissionResultWindow.py b/qt_ui/windows/QWaitingForMissionResultWindow.py index be7cdd2e..e861b911 100644 --- a/qt_ui/windows/QWaitingForMissionResultWindow.py +++ b/qt_ui/windows/QWaitingForMissionResultWindow.py @@ -28,7 +28,6 @@ from qt_ui.windows.GameUpdateSignal import GameUpdateSignal class DebriefingFileWrittenSignal(QObject): - instance = None debriefingReceived = Signal(Debriefing) diff --git a/qt_ui/windows/groundobject/QGroundObjectMenu.py b/qt_ui/windows/groundobject/QGroundObjectMenu.py index 3aea880a..09cc9251 100644 --- a/qt_ui/windows/groundobject/QGroundObjectMenu.py +++ b/qt_ui/windows/groundobject/QGroundObjectMenu.py @@ -70,7 +70,6 @@ class QGroundObjectMenu(QDialog): self.init_ui() def init_ui(self): - self.mainLayout = QVBoxLayout() self.budget = QBudgetBox(self.game) self.budget.setGame(self.game) @@ -105,7 +104,6 @@ class QGroundObjectMenu(QDialog): self.setLayout(self.mainLayout) def doLayout(self): - self.update_total_value() self.intelBox = QGroupBox("Units :") self.intelLayout = QGridLayout() diff --git a/qt_ui/windows/intel.py b/qt_ui/windows/intel.py index bb169152..866c6eef 100644 --- a/qt_ui/windows/intel.py +++ b/qt_ui/windows/intel.py @@ -160,7 +160,6 @@ class IntelWindow(QDialog): self.refresh_layout() def refresh_layout(self) -> None: - # Clear the existing layout if self.layout(): idx = 0 diff --git a/qt_ui/windows/mission/flight/waypoints/QFlightWaypointInfoBox.py b/qt_ui/windows/mission/flight/waypoints/QFlightWaypointInfoBox.py index d26fa330..73435db2 100644 --- a/qt_ui/windows/mission/flight/waypoints/QFlightWaypointInfoBox.py +++ b/qt_ui/windows/mission/flight/waypoints/QFlightWaypointInfoBox.py @@ -14,7 +14,6 @@ class QFlightWaypointInfoBox(QGroupBox): self.init_ui() def init_ui(self) -> None: - layout = QVBoxLayout() x_pos_layout = QHBoxLayout() diff --git a/qt_ui/windows/mission/flight/waypoints/QFlightWaypointTab.py b/qt_ui/windows/mission/flight/waypoints/QFlightWaypointTab.py index 29c5e545..852247d2 100644 --- a/qt_ui/windows/mission/flight/waypoints/QFlightWaypointTab.py +++ b/qt_ui/windows/mission/flight/waypoints/QFlightWaypointTab.py @@ -60,7 +60,6 @@ class QFlightWaypointTab(QFrame): self.recreate_buttons.clear() for task in self.package.target.mission_types(for_player=True): - if ( task == FlightType.AIR_ASSAULT and not self.game.lua_plugin_manager.is_plugin_enabled("ctld") diff --git a/qt_ui/windows/mission/flight/waypoints/QPredefinedWaypointSelectionWindow.py b/qt_ui/windows/mission/flight/waypoints/QPredefinedWaypointSelectionWindow.py index 904c3064..fd2740ba 100644 --- a/qt_ui/windows/mission/flight/waypoints/QPredefinedWaypointSelectionWindow.py +++ b/qt_ui/windows/mission/flight/waypoints/QPredefinedWaypointSelectionWindow.py @@ -27,7 +27,6 @@ PREDEFINED_WAYPOINT_CATEGORIES = [ class QPredefinedWaypointSelectionWindow(QDialog): - # List of FlightWaypoint waypoints_added = Signal(list) diff --git a/qt_ui/windows/preferences/QLiberationPreferences.py b/qt_ui/windows/preferences/QLiberationPreferences.py index f2486834..89374f35 100644 --- a/qt_ui/windows/preferences/QLiberationPreferences.py +++ b/qt_ui/windows/preferences/QLiberationPreferences.py @@ -87,7 +87,6 @@ class QLiberationPreferences(QFrame): self.edit_dcs_install_dir.setText(install_dir) def apply(self): - print("Applying changes") self.saved_game_dir = self.edit_saved_game_dir.text() self.dcs_install_dir = self.edit_dcs_install_dir.text() diff --git a/qt_ui/windows/settings/QSettingsWindow.py b/qt_ui/windows/settings/QSettingsWindow.py index 3f6ac90d..59e008dc 100644 --- a/qt_ui/windows/settings/QSettingsWindow.py +++ b/qt_ui/windows/settings/QSettingsWindow.py @@ -345,7 +345,6 @@ class QSettingsWindow(QDialog): self.setLayout(self.layout) def initCheatLayout(self): - self.cheatPage = QWidget() self.cheatLayout = QVBoxLayout() self.cheatPage.setLayout(self.cheatLayout) diff --git a/qt_ui/windows/stats/QAircraftChart.py b/qt_ui/windows/stats/QAircraftChart.py index c162f48e..0ec67d71 100644 --- a/qt_ui/windows/stats/QAircraftChart.py +++ b/qt_ui/windows/stats/QAircraftChart.py @@ -18,7 +18,6 @@ class QAircraftChart(QFrame): self.setLayout(self.layout) def generateUnitCharts(self): - self.alliedAircraft = [ d.allied_units.aircraft_count for d in self.game.game_stats.data_per_turn ] diff --git a/qt_ui/windows/stats/QArmorChart.py b/qt_ui/windows/stats/QArmorChart.py index fd9f9553..5f8b280c 100644 --- a/qt_ui/windows/stats/QArmorChart.py +++ b/qt_ui/windows/stats/QArmorChart.py @@ -18,7 +18,6 @@ class QArmorChart(QFrame): self.setLayout(self.layout) def generateUnitCharts(self): - self.alliedArmor = [ d.allied_units.vehicles_count for d in self.game.game_stats.data_per_turn ] diff --git a/requirements.txt b/requirements.txt index 9df033c6..0f85a4c1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ annotated-types==0.6.0 anyio==3.7.1 asgiref==3.7.2 attrs==23.1.0 -black==22.12.0 +black==23.11.0 certifi==2023.11.17 cfgv==3.4.0 click==8.1.7 diff --git a/tests/lasercodes/test_lasercode.py b/tests/lasercodes/test_lasercode.py index 581de8ef..49d73acf 100644 --- a/tests/lasercodes/test_lasercode.py +++ b/tests/lasercodes/test_lasercode.py @@ -21,7 +21,6 @@ def mock_registry() -> MockRegistry: def test_lasercode_code(registry: ILaserCodeRegistry) -> None: - assert LaserCode(1688, registry).code == 1688 # 1113 doesn't comply to the rules, but is the only code valid for FC3 aircraft like diff --git a/tests/test_factions.py b/tests/test_factions.py index 58e20667..a8eaa7c6 100644 --- a/tests/test_factions.py +++ b/tests/test_factions.py @@ -99,7 +99,6 @@ class TestFactionLoader(unittest.TestCase): @pytest.mark.skip(reason="Faction unit names in the json files are outdated") def test_load_valid_faction_with_invalid_country(self) -> None: - with (RESOURCES_DIR / "invalid_faction_country.json").open("r") as data: try: Faction.from_dict(json.load(data))