Skip to content

Commit 414cf01

Browse files
committed
update ruff and start applying manual fixes
1 parent de051c8 commit 414cf01

File tree

13 files changed

+903
-905
lines changed

13 files changed

+903
-905
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# https://github.com/python/black#version-control-integration
44
repos:
55
- repo: https://github.com/astral-sh/ruff-pre-commit
6-
rev: v0.9.7
6+
rev: v0.12.0
77
hooks:
88
- id: ruff
99
- id: ruff-format
1010
- repo: https://github.com/pre-commit/mirrors-mypy
11-
rev: v1.15.0
11+
rev: v1.16.1
1212
hooks:
1313
- id: mypy
1414
additional_dependencies: [types-requests]

docs/_static/convert_exchange.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from html import escape
66

77
from js import Uint8Array, console # noqa: F401
8-
from pyscript import display # type: ignore
8+
from pyscript import display
99

1010
from cchdo.hydro import __version__ as hydro_version
1111
from cchdo.hydro import accessors, read_exchange # noqa: F401
@@ -18,7 +18,7 @@ def logger(msg):
1818

1919
class DisplaylHandler(logging.Handler):
2020
def emit(self, record) -> None:
21-
logger(self.formatter.format(record)) # type: ignore
21+
logger(self.formatter.format(record))
2222

2323

2424
root = logging.getLogger()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ dev = [
6868
"pre-commit>=4.1.0",
6969
"pytest-cov>=6.0.0",
7070
"pytest-xdist>=3.6.1",
71-
"ruff>=0.9.7",
71+
"ruff>=0.12.0",
7272
"types-requests>=2.32.0.20241016",
7373
]
7474
docs = [

src/cchdo/hydro/__main__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,7 @@ def status_exchange(
268268

269269
out_path = Path(out_dir)
270270
cruises, files = cchdo_loader(dtype)
271-
file_paths = []
272-
for file in track(files, description="Loading data files"):
273-
file_paths.append((cached_file_loader(file), file))
271+
file_paths = [(cached_file_loader(file), file) for file in track(files, description="Loading data files")]
274272

275273
results = []
276274
all_unknown_params = {}

src/cchdo/hydro/__main_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import xarray as xr
66

7-
from cchdo.hydro import accessors # noqa
7+
from cchdo.hydro import accessors # noqa: F401
88
from cchdo.hydro.exchange import read_exchange
99
from cchdo.hydro.exchange.exceptions import (
1010
ExchangeDataFlagPairError,

src/cchdo/hydro/accessors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ def compact_profile(self):
544544
)
545545
return self._obj.isel(N_LEVELS=(self._obj.sample != "")[0])
546546

547-
date_names = {WHPNames["DATE"], WHPNames["BTL_DATE"]}
548-
time_names = {WHPNames["TIME"], WHPNames["BTL_TIME"]}
547+
date_names = frozenset((WHPNames["DATE"], WHPNames["BTL_DATE"]))
548+
time_names = frozenset((WHPNames["TIME"], WHPNames["BTL_TIME"]))
549549

550550
@property
551551
def file_type(self):

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 # numpy doesn't support __array_ufunc__ types yet
134+
fill_value_mismatch: xr.DataArray = ~(np.isfinite(data) ^ has_fill) #type: ignore[assignment]
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"

src/cchdo/hydro/exchange/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,7 @@ def _load_raw_exchange(
837837
# lets just try "reading"
838838
elif hasattr(filename_or_obj, "read"):
839839
log.info("Loading object open file object")
840-
# https://github.com/python/mypy/issues/1424
841-
data_raw = io.BytesIO(filename_or_obj.read()) # type: ignore
840+
data_raw = io.BytesIO(filename_or_obj.read())
842841

843842
elif isinstance(filename_or_obj, bytes | bytearray):
844843
log.info("Loading raw data bytes")

src/cchdo/hydro/legacy/coards/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,9 @@ def get_dataarrays(ds: xr.Dataset):
307307

308308
if data.dtype.kind in "iuf":
309309
if np.all(np.isnan(data)):
310-
attrs["data_min"] = float("-inf") # type: ignore
311-
attrs["data_max"] = float("inf") # type: ignore
310+
# the proper fix here would be to make a type dict that knows what is going on with each key
311+
attrs["data_min"] = float("-inf") # type: ignore[assignment]
312+
attrs["data_max"] = float("inf") # type: ignore[assignment]
312313
else:
313314
attrs["data_min"] = np.nanmin(data)
314315
attrs["data_max"] = np.nanmax(data)

src/cchdo/hydro/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)