From 8e33d531f2bce14ef7c76934ea9377cd821e134f Mon Sep 17 00:00:00 2001 From: Brendan Collins Date: Wed, 1 Jul 2026 22:48:07 -0400 Subject: [PATCH] Fix isort drift in geotiff writer and symbology test (#3588) --- .claude/sweep-style-state.csv | 2 +- xrspatial/geotiff/_writers/eager.py | 1 + xrspatial/geotiff/tests/write/test_symbology_sidecar_3537.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.claude/sweep-style-state.csv b/.claude/sweep-style-state.csv index 6e60a36bc..b84f4b020 100644 --- a/.claude/sweep-style-state.csv +++ b/.claude/sweep-style-state.csv @@ -7,7 +7,7 @@ dasymetric,2026-06-20,3411,HIGH,1;3;4,"F401 is_dask_cupy unused (HIGH); E128 lin diffusion,2026-06-20,3421,HIGH,3;4,F401 unused not_implemented_func (HIGH); isort import-ordering drift (MEDIUM); no Cat1/2/5. Fixed in PR off issue 3421. fire,2026-06-19,3395,HIGH,3;4,Cat3 F401 math.log unused + F841 S_T unused local; Cat4 isort utils import reorder. No Cat1/2/5. Fixed in #3395 rockout. focal,2026-05-29,2731,HIGH,3;4;5,"F401 not_implemented_func (import line 36, unused, not re-exported). isort: stdlib reorder (import math before from-imports), dropped stray blank lines in import groups, alphabetised+rewrapped convolution/utils from-imports, moved dataset_support import into order. Cat 5: mutable default excludes=[np.nan] in mean() (line 238) -> None sentinel, resolved to [np.nan] in body; never mutated so behaviour preserved; regression test test_mean_default_excludes_does_not_leak added. Cat 1/2 clean. 115 focal tests pass. PR pending." -geotiff,2026-06-25,,MEDIUM,4,"Re-sweep 2026-06-25 (file last modified 2026-06-24). flake8 baseline 0 across all 35 production files AND all tests (flake8 7.x, max-line-length=100). Cat 4 only: one isort (line_length=100) finding in tests/unit/test_exception_exports_3265.py - the deferred 'from xrspatial.geotiff._reader import PixelSafetyLimitError as reader_pixel_err' was written with a backslash continuation but joins to 83 chars, so isort wants it on one line. Joined it; formatting only, no behaviour change. Cat 1/2/3/5 clean: no E/W/F codes; grep hits for == False (a comment), ': dict'/': list' annotations, and type=getaddrinfo kwarg are false positives (not shadowed builtins or comparisons). isort+flake8 clean after fix; tests collect ok. Issue-create denied by auto-mode classifier; fix committed to deep-sweep branch; PR #3517 opened." +geotiff,2026-07-01,3588,MEDIUM,4,"Re-sweep 2026-07-01. flake8 baseline 0 across subpackage (36 source files + tests). Cat 4 only: isort drift in _writers/eager.py (missing blank line after inline resolve_ramp import) and tests/write/test_symbology_sidecar_3537.py (parenthesized import joins to one line at 100 cols + blank line after inline cupy import); both introduced by #3537 symbology work. Cat 1/2/3/5 clean (shadow-grep hits are annotations, getaddrinfo type= kwarg, and QML XML strings - false positives). Fixed by running isort on the two files; flake8+isort clean after; 25 symbology tests pass (CUDA available). Issue #3588; PR from deep-sweep-style-geotiff-2026-07-01." hydro-d8,2026-05-29,2705,HIGH,1;3;4,"flake8+isort over the 13 D8 files only (dinf/mfd out of scope). Cat 3 HIGH: F401 x2 (flow_length_d8 function-local _compute_accum_seeds never called; snap_pour_point_d8 module-level cuda_args unused) - both confirmed dead, no re-export. Cat 1: E127/E128 continuation-indent x90 (mostly multi-line def signatures); E302/E303 blank-line cluster in watershed_d8; E501 x4 (flow_path_d8 + snap_pour_point_d8, wrapped ternaries). Cat 4: isort import-block reordering on all 13 files. No Cat 2 (W-codes), no Cat 5 (grep clean: no bare except, mutable defaults, ==None/==True, or shadowed builtins). flake8+isort clean after fix; 385 D8 tests pass. flow_direction_d8 needed manual blank-line placement to satisfy both isort and E302." interpolate,2026-06-12,3286,HIGH,3;4,"Full subpackage sweep (_idw, _kriging, _spline, _validation). Cat 3 F401: unused 'import math' in _idw.py L5 (IDW kernels are pure arithmetic; _spline.py keeps math for math.log in TPS kernels; not re-exported, __init__ exports only idw/kriging/spline). Cat 4 isort: _idw.py + _spline.py 5-line xrspatial.utils from-import reflowed to 2 lines under line_length=100, matching _kriging.py from #2916. Cat 1/2/5 clean (no E/W codes; grep: no bare except, mutable defaults, ==None/True, shadowed builtins). flake8+isort clean after fix; 66 interpolation tests pass (CUDA available). PR open." interpolate-kriging,2026-06-04,2916,MEDIUM,1;4,"flake8 E128 x2: continuation-line under-indent at the _chunk_var kriging-predict calls in _kriging_dask_numpy (L234) and _kriging_dask_cupy (L324); re-indented to visual-indent column. Cat 4 isort: 5-line from xrspatial.utils (...) block collapses to one 88-char line under line_length=100. Cat 2/3/5 grep clean (no W-codes, F-codes, bare except, mutable defaults, ==None/True, or shadowed builtins). flake8+isort clean after fix; 14 kriging tests pass. PR open." diff --git a/xrspatial/geotiff/_writers/eager.py b/xrspatial/geotiff/_writers/eager.py index dfa148cbe..b524adc74 100644 --- a/xrspatial/geotiff/_writers/eager.py +++ b/xrspatial/geotiff/_writers/eager.py @@ -500,6 +500,7 @@ def to_geotiff(data: xr.DataArray | np.ndarray, # when packing rather than emit a mismatched ramp. if color_ramp and not _cat_names and not pack: from .._symbology import resolve_ramp + # Validate the ramp name now so a typo fails before any bytes. _sym_stops = resolve_ramp(color_ramp) _sym_data = data diff --git a/xrspatial/geotiff/tests/write/test_symbology_sidecar_3537.py b/xrspatial/geotiff/tests/write/test_symbology_sidecar_3537.py index 73c77a6ac..1355d0a46 100644 --- a/xrspatial/geotiff/tests/write/test_symbology_sidecar_3537.py +++ b/xrspatial/geotiff/tests/write/test_symbology_sidecar_3537.py @@ -19,8 +19,7 @@ from xrspatial.geotiff import to_geotiff from xrspatial.geotiff._pam import build_stats_pam_xml -from xrspatial.geotiff._symbology import ( - _finite_stats, build_qml, qml_path, resolve_ramp) +from xrspatial.geotiff._symbology import _finite_stats, build_qml, qml_path, resolve_ramp from .._helpers.markers import requires_gpu @@ -117,6 +116,7 @@ def test_finite_stats_backend_parity(): pytest.importorskip("cupy") import cupy + from xrspatial.utils import has_cuda_and_cupy if not has_cuda_and_cupy(): pytest.skip("no CUDA device")