A style audit of xrspatial/proximity.py using the project's configured flake8 (max-line-length=100) and isort (line_length=100) settings turned up four issues. None of them break correctness on their own, but two touch runtime semantics, so it makes sense to fix them in one pass.
flake8 F841: dead local (line 1274)
original_chunks = raster.data.chunks is assigned in the unbounded dask+cupy branch and never read. It is a refactor leftover from when chunk geometry was restored after the cupy-to-numpy conversion. Remove it.
Mutable default argument (lines 1347, 1490, 1630)
The three public functions proximity, allocation, and direction declare target_values: list = []. A mutable default is shared across all calls. The current code never mutates it, so there is no live bug, but the pattern is fragile. Switch to a None sentinel and normalize to [] inside the body so behaviour stays identical.
flake8 E128: continuation line under-indent (line 291)
The nested np.where in _vectorized_calc_direction is under-indented for the visual indent. Reflow it.
isort: import ordering (lines 27-32)
The three from xrspatial... imports are not in the order isort expects under line_length=100. Re-sort.
Scope
- No behavioural change for the E128 reflow or the isort reordering.
- The F841 removal deletes dead code only.
- The mutable-default fix preserves behaviour (None normalizes to
[]).
- No flake8 or isort config changes, no autoformatter.
After the fix, flake8 xrspatial/proximity.py and isort --check-only xrspatial/proximity.py should both pass clean.
A style audit of
xrspatial/proximity.pyusing the project's configured flake8 (max-line-length=100) and isort (line_length=100) settings turned up four issues. None of them break correctness on their own, but two touch runtime semantics, so it makes sense to fix them in one pass.flake8 F841: dead local (line 1274)
original_chunks = raster.data.chunksis assigned in the unbounded dask+cupy branch and never read. It is a refactor leftover from when chunk geometry was restored after the cupy-to-numpy conversion. Remove it.Mutable default argument (lines 1347, 1490, 1630)
The three public functions
proximity,allocation, anddirectiondeclaretarget_values: list = []. A mutable default is shared across all calls. The current code never mutates it, so there is no live bug, but the pattern is fragile. Switch to aNonesentinel and normalize to[]inside the body so behaviour stays identical.flake8 E128: continuation line under-indent (line 291)
The nested
np.wherein_vectorized_calc_directionis under-indented for the visual indent. Reflow it.isort: import ordering (lines 27-32)
The three
from xrspatial...imports are not in the order isort expects underline_length=100. Re-sort.Scope
[]).After the fix,
flake8 xrspatial/proximity.pyandisort --check-only xrspatial/proximity.pyshould both pass clean.