aspect: fix flake8 E402/E305/E501 in aspect.py#2740
Open
brendancol wants to merge 3 commits into
Open
Conversation
Move the xrspatial.geodesic import up with the other top-of-file imports (it sat below _geodesic_cuda_dims, triggering E402 + E305). Wrap two over-long _run_gpu_geodesic_aspect kernel-launch calls (E501). Style only, no behavioural change. isort reordering intentionally not applied: slope.py/curvature.py use one-import-per-line for xrspatial.utils, and raw isort would make aspect inconsistent with them.
brendancol
commented
May 30, 2026
Contributor
Author
brendancol
left a comment
There was a problem hiding this comment.
PR Review: aspect: fix flake8 E402/E305/E501 in aspect.py
Blockers
None.
Suggestions
None.
Nits
None.
What looks good
- The diff is exactly the three intended changes and nothing else. No adjacent code touched.
- Relocating the
xrspatial.geodesicimport to the top is semantically identical. The module imports cleanly with no dependency on_geodesic_cuda_dims, confirmed by the passing test run. This also resolves the real readability problem of an import hidden below a function def. - Both line-wraps are whitespace-only inside the argument lists of the
_run_gpu_geodesic_aspect[...]kernel launches. No behavioural change. - The decision to skip the isort reordering is correct: slope.py and curvature.py use one-import-per-line for
xrspatial.utils, so applying the raw isort diff would make aspect the odd one out. Documented in the PR body rather than silently suppressed.
Checklist
- Algorithm matches reference/paper (no algorithm change)
- All implemented backends produce consistent results (static reformat; shared source)
- NaN handling is correct (untouched)
- Edge cases are covered by tests (existing suite exercises every changed line)
- Dask chunk boundaries handled correctly (untouched)
- No premature materialization or unnecessary copies (no compute change)
- Benchmark exists or is not needed (not needed for a style fix)
- README feature matrix updated (not applicable)
- Docstrings present and accurate (untouched)
Verified locally: flake8 xrspatial/aspect.py clean; pytest test_aspect.py 64 passed; pytest test_geodesic_aspect.py 18 passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2683
What
from xrspatial.geodesic import (...)block from below_geodesic_cuda_dimsup to the other top-of-file imports. Fixes E402 (import not at top) and E305 (blank lines after function def)._run_gpu_geodesic_aspect[griddim, blockdim](...)kernel-launch calls. Fixes both E501 (101 and 109 chars).flake8 xrspatial/aspect.pynow reports zero violations.Categories addressed
Cat 1 (flake8 E-codes: E402, E305, E501).
Cat 4 (isort) was reviewed and intentionally not applied: slope.py and curvature.py use one-import-per-line for
xrspatial.utils, andisort --check-onlyflags them the same way. Applying the raw isort diff would collapse aspect's imports and make it inconsistent with its sibling terrain modules. No config widening, no# noqa.Cat 2, Cat 3, and Cat 5 (bare except / mutable defaults /
== None/ shadowed builtins) were grepped and are clean.No behavioural change
Static reformatting only. All four backends (numpy / cupy / dask+numpy / dask+cupy) share the same source, so no backend-specific verification is needed.
Test plan
flake8 xrspatial/aspect.pycleanpytest xrspatial/tests/test_aspect.py(64 passed)pytest xrspatial/tests/test_geodesic_aspect.py(18 passed)aspect/northness/eastness