Skip to content

geotiff: fix flake8/isort style drift in tests and two source imports#2972

Merged
brendancol merged 2 commits into
mainfrom
deep-sweep-style-geotiff-2970
Jun 5, 2026
Merged

geotiff: fix flake8/isort style drift in tests and two source imports#2972
brendancol merged 2 commits into
mainfrom
deep-sweep-style-geotiff-2970

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Closes #2970.

The geotiff subpackage has no flake8 or isort check in CI, so style drift had piled up. Running the project's configured tooling (setup.cfg: flake8 max-line-length=100, isort line_length=100) found a small set of issues, all confirmed by the tools. The 33 source files were already clean except for two import blocks.

What changed

  • Cat 3 (pyflakes F-codes): removed dead test code.
    • tests/unit/test_geotags.py: dropped two redundant local import struct statements (F811) so the single module-level import is the one in use (clears F401).
    • tests/unit/test_metadata.py: removed the unused local ascii_buf (F841).
  • Cat 1 (E501): tests/unit/test_metadata.py over-length import reflowed by isort.
  • Cat 2 (W391): trailing blank line at the end of tests/unit/test_geotags.py.
  • Cat 4 (isort): import ordering in __init__.py and _writers/eager.py, plus about 40 test files, normalized to the configured profile.

No behavioural change

Cat 1/2/4 are formatting only. The Cat 3 removals delete code that the tools confirm is never executed (dead imports and an unused local), so runtime is unchanged.

One detail worth flagging: three golden_corpus test files have imports below module-level setup that carry # noqa: E402. isort split those into one-per-line, which dropped the noqa from the second line, so I re-added # noqa: E402 to keep flake8 quiet on the intentional late import. isort is stable and idempotent after that.

Scope

No black/autopep8/ruff-format, no config widening. Fixes limited to what flake8 + isort report.

Test plan

  • flake8 xrspatial/geotiff/ reports 0
  • isort --check-only xrspatial/geotiff/ clean and idempotent
  • pytest xrspatial/geotiff/tests/unit/test_geotags.py xrspatial/geotiff/tests/unit/test_metadata.py (171 passed)
  • patched golden_corpus files collect and import cleanly

Found by /sweep-style.

…#2970)

Remove dead test code flagged by pyflakes and normalize import
ordering across the geotiff subpackage using the project's configured
isort (line_length=100) and flake8 (max-line-length=100).

Cat 3 (pyflakes F-codes):
- test_geotags.py: drop redundant local 'import struct' in two
  functions (F811) so the single module-level import is used (F401)
- test_metadata.py: remove unused local 'ascii_buf' (F841)

Cat 1 (E501): test_metadata.py over-length import reflowed by isort
Cat 2 (W391): test_geotags.py trailing blank line at EOF
Cat 4 (isort): __init__.py and _writers/eager.py import blocks plus
  ~40 test files reordered to the configured profile

Three golden_corpus imports keep their '# noqa: E402' after isort
split them to one-per-line. No behavioural change.

Closes #2970
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Jun 5, 2026
Copy link
Copy Markdown
Contributor Author

@brendancol brendancol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: geotiff flake8/isort style cleanup

Style-only change. No numerical, dask, or cupy code is touched, so the correctness/backend sections of the checklist are not applicable. I focused on the risk that actually matters for this kind of PR: did isort or the dead-code removal drop a symbol that is still needed?

Blockers

None.

Suggestions

None.

Nits

None.

What looks good

  • The two source-file changes (__init__.py, _writers/eager.py) are pure import reflow to line_length=100. No symbol added or removed.
  • The struct cleanup in test_geotags.py keeps the module-level import struct (still present at line 4) and drops only the two redundant function-local re-imports. struct is used throughout both functions via the module-level binding, so this is correct.
  • The ascii_buf removal in test_metadata.py deletes a local that was assigned and never read.
  • The # noqa: E402 handling on the three golden_corpus files is the one spot that needed care: isort split a parenthesized import into one-per-line, which would have stranded the second line without its noqa. Both lines now carry # noqa: E402, and flake8 is clean.

Verification

  • flake8 xrspatial/geotiff/ reports 0; isort --check-only is clean and idempotent (no further changes on a repeat run).
  • Full geotiff suite collects: 6208 tests, no import errors, so nothing was dropped by the reorder.
  • pytest on the two directly edited unit files: 171 passed.

Checklist

  • No behavioural change (formatting + confirmed-dead code only)
  • No import symbol dropped (full-suite collection clean)
  • flake8 and isort clean and idempotent
  • Scope held to what the tools report (no formatter, no config widening)
  • Algorithm / backend / NaN checks: not applicable (no compute code changed)

…iff-2970

# Conflicts:
#	xrspatial/geotiff/tests/vrt/test_metadata.py
@brendancol brendancol merged commit 34b8195 into main Jun 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

geotiff: clean up flake8/isort style drift in tests and two source imports

1 participant