mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fix unreachable code issues, enable checking.
The loadout case actually could (and previously did) hide bugs from the type checker, since mypy was smart enough to see that we were removing None from the input it assumed that the member was non-optional, but later modifications could cause null values, and since those came from the UI mypy couldn't reason about this. This meant that mypy assumed the type could not be optional and wouldn't check that case.
This commit is contained in:
parent
29753a6aa9
commit
299ed88f09
@ -219,11 +219,7 @@ class FlightPlan:
|
|||||||
tot_waypoint = self.tot_waypoint
|
tot_waypoint = self.tot_waypoint
|
||||||
if tot_waypoint is None:
|
if tot_waypoint is None:
|
||||||
return None
|
return None
|
||||||
|
return self.tot - self._travel_time_to_waypoint(tot_waypoint)
|
||||||
time = self.tot
|
|
||||||
if time is None:
|
|
||||||
return None
|
|
||||||
return time - self._travel_time_to_waypoint(tot_waypoint)
|
|
||||||
|
|
||||||
def startup_time(self) -> Optional[timedelta]:
|
def startup_time(self) -> Optional[timedelta]:
|
||||||
takeoff_time = self.takeoff_time()
|
takeoff_time = self.takeoff_time()
|
||||||
|
|||||||
@ -19,7 +19,11 @@ class Loadout:
|
|||||||
is_custom: bool = False,
|
is_custom: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.name = name
|
self.name = name
|
||||||
self.pylons = {k: v for k, v in pylons.items() if v is not None}
|
# We clear unused pylon entries on initialization, but UI actions can still
|
||||||
|
# cause a pylon to be emptied, so make the optional type explicit.
|
||||||
|
self.pylons: Mapping[int, Optional[Weapon]] = {
|
||||||
|
k: v for k, v in pylons.items() if v is not None
|
||||||
|
}
|
||||||
self.date = date
|
self.date = date
|
||||||
self.is_custom = is_custom
|
self.is_custom = is_custom
|
||||||
|
|
||||||
|
|||||||
2
mypy.ini
2
mypy.ini
@ -13,7 +13,7 @@ namespace_packages = True
|
|||||||
no_implicit_optional = True
|
no_implicit_optional = True
|
||||||
warn_redundant_casts = True
|
warn_redundant_casts = True
|
||||||
# warn_return_any = True
|
# warn_return_any = True
|
||||||
# warn_unreachable = True
|
warn_unreachable = True
|
||||||
warn_unused_ignores = True
|
warn_unused_ignores = True
|
||||||
|
|
||||||
[mypy-dcs.*]
|
[mypy-dcs.*]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user