fix: AttributeError in single-output mode with XML/o5m output#77
fix: AttributeError in single-output mode with XML/o5m output#77agrenott merged 2 commits intoagrenott:masterfrom
Conversation
typing.cast() is a static-analysis no-op and does not construct a
BBox NamedTuple at runtime. The area string was being parsed into a
plain list and passed downstream, causing AttributeError when
make_bounds_tag() accessed bbox.min_lat (XML/o5m output paths).
Replace cast("BBox", [...]) with BBox(*[...]) to actually instantiate
the NamedTuple, and add a regression test verifying the correct type
is passed to get_osm_output in single-output mode.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for the proposal. |
|
Thanks for the review! Also updated the PR summary, the original description incorrectly framed this as specific to areas with no elevation data. The crash happens in single-output mode with XML/o5m output regardless, as the repro below shows. Reproduction: pyhgtmap -a 6:43:7:44 --max-nodes-per-tile=0 tests/data/N43E006.hgtRoot cause: Longer-term, storing |
Summary
AttributeError: 'list' object has no attribute 'min_lat'crash when running in single-output mode (--maxNodesPerTile=0) with XML or o5m output.typing.cast()is a runtime no-op — it returns its second argument unchanged. The old code passed a plainlist[float]where aBBoxNamedTuple was expected, which fails when downstream code accesses named fields like.min_lat. The fix constructs an actualBBox, which also required moving the import out ofTYPE_CHECKING.test_process_files_single_output_bbox_type— the existingtest_process_files_single_outputE2E test uses PBF output, which unpacksbboxas a tuple and silently accepts a plain list; this new test targets the XML/o5m path by assertingget_osm_outputreceives a properBBoxinstance, catching the exact failure mode.Traceback
Test plan
hatch run fmt— formatting passeshatch run test— 296 passed, 5 skippedtest_process_files_single_output_bbox_typecovers the exact failure path🤖 Generated with Claude Code