Cleaning Up: Resolving 33 F821 Errors In 6 Test Files
Cleaning Up: Resolving 33 F821 Errors in 6 Test Files Overlooked by #314 Scout
Introduction
Following the Block B sweep in issue #314, which initially addressed 104 F821 errors, a fresh scan of the main branch revealed 33 additional F821 errors in 6 test files that the original flake8 scout did not flag. Let's dive into the details and tackle this mop-up task.
Understanding the Missed Errors
The original scout run immediately after a uv run --extra dev cold start triggered a 4m31s bytecode compile and then errored (Failed to spawn: flake8). The second invocation returned quickly and reported 104 errors. However, a third scan post-merge reported 29 errors, and a fourth scan returned 66, which reduced to 33 after the mop-up. The inconsistent output count across runs suggests a flake8/uv-env interaction where incomplete scans return successfully with partial results. While worth investigating, this issue should not block the mop-up pull requests.
The 33 Remaining F821 Errors
Here's a breakdown of the 33 remaining F821 errors across the 6 test files:
| File | Count | Undefined names |
|---|---|---|
tests/unit/marine_safety/test_validators.py |
20 | CoordinateValidator (7), DateValidator (6), IMOValidator (4), ValidationResult (3) |
tests/unit/marine_safety/test_uscg_scraper.py |
8 | USCGScraper (1), RateLimiter (4), RetryStrategy (3) |
tests/test_compliance_standalone.py |
2 | ProductionQuota, RegulatoryMilestone |
tests/performance/test_critical_operations.py |
1 | Engine |
tests/modules/sodir-integration/test_integration.py |
1 | SodirModule |
tests/modules/bsee/analysis/comprehensive-report-system/test_visualization_system.py |
1 | ChartBuilder |
Pattern Recognition
The marine_safety test files (28 of the 33) likely share the same broken-import problem as the comprehensive-report-system/ tests fixed in issues #320 and #321 - stale paths or missing imports of classes that live under src/worldenergydata/marine_safety/. Three of the six files reference names like SodirModule, ChartBuilder, Engine that may be orphaned references to removed/renamed code.
Recommended Investigation Order
To tackle these errors efficiently, follow this investigation order (highest-yield first):
test_validators.py(20 errors, 4 undefined names) - Check whetherCoordinateValidator/DateValidator/IMOValidator/ValidationResultexist insrc/worldenergydata/marine_safety/and add proper imports.test_uscg_scraper.py(8 errors, 3 undefined names) - Same check forUSCGScraper/RateLimiter/RetryStrategy.- Remaining 4 files (5 errors total) - One-off checks, likely orphaned references.
Acceptance Criteria
- [ ]
uv run --extra dev flake8 src/ tests/ --select=F821returns 0 on main - [ ] Any pre-existing test failures surfaced by fixing imports are documented (xfail with reason, matching #320's pattern) rather than silently re-broken
- [ ] Scout reliability
- Note in the PR description how you confirmed the final count is stable (e.g., run flake8 twice and confirm the same count)
Priority
Medium. Not a regression from the Block B sweep - these were always broken. But worth finishing so #314 can close cleanly.