feat: type Event.distance as float for non-integer distances - #29
Open
fsalum wants to merge 1 commit into
Open
Conversation
egelja
requested changes
Aug 16, 2026
Contributor
Author
I'm only a bit hesitant to that because it would affect anybody using the library, they will start seeing some events with 2.4 FR swimming that is not pool but open water events. Worth perhaps bumping the version to 3.0 (backwards compatible but the data changed). Let me know if you still want that and I'm fine updating it. |
Contributor
|
Yep, I'm fine with bumping. Let's do it! |
The E1/F1 distance field (6 chars) can contain non-integer values — e.g. "2.4" for 2.4 miles in open-water meets. safe_cast(int, "2.4") raised ValueError and fell back to int() = 0, permanently losing the value. Type Event.distance as float and parse it with safe_cast(float, ...) so these distances survive. Integer distances now come through as floats (100 -> 100.0); this is an API-compatible data change, so callers reading distance as an int should coerce. Blank/non-numeric fields still yield 0.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fsalum
force-pushed
the
feat/distance-raw
branch
from
August 16, 2026 23:14
f3b553d to
34cb26f
Compare
Contributor
Author
|
Updated. |
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.
Summary
The E1/F1 distance field (6 chars) can contain non-integer values — for example,
"2.4"representing 2.4 miles in open-water meets.safe_cast(int, "2.4")raisesValueErrorand falls back toint()= 0, permanently losing the original value.Per review, this PR types
Event.distanceasfloat(rather than adding a paralleldistance_raw) and parses it withsafe_cast(float, ...), so non-integer distances survive the parse.Changes
schemas.py:Event.distanceis nowfloat.get_or_create_event'sdistanceparam is typedfloat.e_event_parsers.py/f_relay_parsers.py:distance = safe_cast(float, extract(line, 16, 6)).Compatibility
This is an API-compatible but data-changing release: integer distances now come through as floats (
100→100.0), and callers that previously readdistanceas anint(e.g. keying events on it) should coerce. Blank/non-numeric fields still yield0.0. Worth a major version bump.Tests
"2.4"→distance=2.4)"1000"→distance=1000.0)distance=0.0All 116 tests pass.