Skip to content

Commit 11ff7c4

Browse files
committed
fix more type errors in __main
1 parent f5c621a commit 11ff7c4

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/cchdo/hydro/__main__.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ def _comment_loader(str_or_path: str) -> str:
5555
type=str,
5656
help="either a comment string or file path prefixed with @ (e.g. @README.txt)",
5757
)
58-
def convert_exchange(exchange_path, out_path, check_flag, precision_source, comments):
58+
def convert_exchange(
59+
exchange_path, out_path, check_flag: bool, precision_source, comments
60+
):
5961
setup_logging("DEBUG")
6062
log.info("Loading read_exchange")
61-
from .exchange import read_exchange
63+
from .exchange import CheckOptions, read_exchange
6264

63-
checks = {"flags": check_flag}
65+
checks: CheckOptions = {"flags": check_flag}
6466

6567
ex = read_exchange(exchange_path, checks=checks, precision_source=precision_source)
6668
log.info("Saving to netCDF")
@@ -91,9 +93,9 @@ def convert_exchange(exchange_path, out_path, check_flag, precision_source, comm
9193
def convert_csv(csv_path, out_path, ftype, check_flag, precision_source, comments):
9294
setup_logging("DEBUG")
9395
log.info("Loading read_exchange")
94-
from .exchange import read_csv
96+
from .exchange import CheckOptions, read_csv
9597

96-
checks = {"flags": check_flag}
98+
checks: CheckOptions = {"flags": check_flag}
9799

98100
ex = read_csv(
99101
csv_path, ftype=ftype, checks=checks, precision_source=precision_source
@@ -134,9 +136,11 @@ def edit_comments(expocode, dtype):
134136
extant_ids = cruise_file_ids & files.keys()
135137
edit_files = list(
136138
filter(
137-
lambda x: x["role"] == "dataset"
138-
and x["data_format"] == "cf_netcdf"
139-
and x["data_type"] == dtype,
139+
lambda x: (
140+
x["role"] == "dataset"
141+
and x["data_format"] == "cf_netcdf"
142+
and x["data_type"] == dtype
143+
),
140144
(files[id] for id in extant_ids),
141145
)
142146
)

src/cchdo/hydro/__main_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import xarray as xr
66

77
from cchdo.hydro import accessors # noqa: F401
8-
from cchdo.hydro.exchange import read_exchange
8+
from cchdo.hydro.exchange import CheckOptions, read_exchange
99
from cchdo.hydro.exchange.exceptions import (
1010
ExchangeDataFlagPairError,
1111
ExchangeParameterUndefError,
@@ -24,7 +24,7 @@ def make_netcdf_file_json(path):
2424

2525
def p_file(file_m):
2626
t_dir, file, file_metadata, roundtrip = file_m
27-
checks = {"flags": False}
27+
checks: CheckOptions = {"flags": False}
2828
unknown_params = []
2929

3030
warnings.simplefilter("ignore")

src/cchdo/hydro/checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def check_flags(dataset: xr.Dataset, raises=True):
131131
# TODO deal with strs
132132

133133
if np.issubdtype(data.values.dtype, np.number):
134-
fill_value_mismatch: xr.DataArray = ~(np.isfinite(data) ^ has_fill) # type: ignore[assignment]
134+
fill_value_mismatch: xr.DataArray = ~(np.isfinite(data) ^ has_fill)
135135
if np.any(fill_value_mismatch):
136136
fill_value_mismatch.attrs["comments"] = (
137137
f"This is a boolean array in the same shape as '{data.name}' which is truthy where invalid values exist"

0 commit comments

Comments
 (0)