Skip to content

Commit c11306c

Browse files
committed
Fix some mypy errors
1 parent 4901fed commit c11306c

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

src/virtualship/expedition/do_expedition.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ def do_expedition(expedition_dir: str | Path, input_data: Path | None = None) ->
5050
checkpoint.verify(schedule)
5151

5252
# load fieldsets
53-
input_data = _load_input_data(
53+
loaded_input_data = _load_input_data(
5454
expedition_dir=expedition_dir,
5555
schedule=schedule,
5656
ship_config=ship_config,
5757
input_data=input_data,
5858
)
5959

6060
# verify schedule is valid
61-
schedule.verify(ship_config.ship_speed_knots, input_data)
61+
schedule.verify(ship_config.ship_speed_knots, loaded_input_data)
6262

6363
# simulate the schedule
6464
schedule_results = simulate_schedule(
@@ -98,7 +98,7 @@ def do_expedition(expedition_dir: str | Path, input_data: Path | None = None) ->
9898
simulate_measurements(
9999
expedition_dir,
100100
ship_config,
101-
input_data,
101+
loaded_input_data,
102102
schedule_results.measurements_to_simulate,
103103
)
104104
print("Done simulating measurements.")
@@ -131,6 +131,10 @@ def _load_input_data(
131131
space_time_region_hash = get_space_time_region_hash(schedule.space_time_region)
132132
input_data = get_existing_download(expedition_dir, space_time_region_hash)
133133

134+
assert input_data is not None, (
135+
"Input data hasn't been found. Have you run the `virtualship fetch` command?"
136+
)
137+
134138
return InputData.load(
135139
directory=input_data,
136140
load_adcp=ship_config.adcp_config is not None,

src/virtualship/expedition/input_data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def load(
4343
:param load_ship_underwater_st: Whether to load the ship underwater ST fieldset.
4444
:returns: An instance of this class with loaded fieldsets.
4545
"""
46+
directory = Path(directory)
4647
if load_drifter:
4748
drifter_fieldset = cls._load_drifter_fieldset(directory)
4849
else:
@@ -152,7 +153,7 @@ def _load_drifter_fieldset(cls, directory: Path) -> FieldSet:
152153
return fieldset
153154

154155
@classmethod
155-
def _load_argo_float_fieldset(cls, directory: str | Path) -> FieldSet:
156+
def _load_argo_float_fieldset(cls, directory: Path) -> FieldSet:
156157
filenames = {
157158
"U": directory.joinpath("argo_float_uv.nc"),
158159
"V": directory.joinpath("argo_float_uv.nc"),

src/virtualship/expedition/schedule.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
import itertools
66
from datetime import datetime, timedelta
77
from pathlib import Path
8+
from typing import TYPE_CHECKING
89

910
import pydantic
1011
import pyproj
1112
import yaml
1213
from parcels import FieldSet
1314

1415
from ..location import Location
15-
from .input_data import InputData
1616
from .ship_config import InstrumentType
1717
from .space_time_region import SpaceTimeRegion
1818

19+
if TYPE_CHECKING:
20+
from .input_data import InputData
1921
projection: pyproj.Geod = pyproj.Geod(ellps="WGS84")
2022

2123

src/virtualship/expedition/simulate_measurements.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
"""simulate_measurements function."""
22

3+
from __future__ import annotations
4+
35
from datetime import timedelta
46
from pathlib import Path
7+
from typing import TYPE_CHECKING
58

69
from ..instruments.adcp import simulate_adcp
710
from ..instruments.argo_float import simulate_argo_floats
811
from ..instruments.ctd import simulate_ctd
912
from ..instruments.drifter import simulate_drifters
1013
from ..instruments.ship_underwater_st import simulate_ship_underwater_st
1114
from ..instruments.xbt import simulate_xbt
12-
from .input_data import InputData
1315
from .ship_config import ShipConfig
1416
from .simulate_schedule import MeasurementsToSimulate
1517

18+
if TYPE_CHECKING:
19+
from .input_data import InputData
20+
1621

1722
def simulate_measurements(
1823
expedition_dir: str | Path,

0 commit comments

Comments
 (0)