Accept integers for float attributes in the YAML frontend (backport #1068) #1071
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 272 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.336
Real PR Conversation Timeline
1 comments
"Review active on #1071"
general
weight: 0.35
ahcorde
Description
In YAML launch files, a float attribute written as a whole number fails to parse.
period: 5on atimerraisesTypeError: Attribute 'period' of Entity 'timer' expected to be of type '<class 'float'>', got '<class 'int'>', andsigterm_timeout,sigkill_timeoutandrespawn_delayonexecutablefail the same way (#1067). YAML loads5as anint, andEntity.get_attrinlaunch_yamlchecks it withis_instance_of(data, float), which rejects ints. The XML frontend converts the attribute string, andperiod="5"works there.This PR converts a plain
inttofloatinlaunch_yaml'sEntity.get_attrwhendata_typeisfloat. The check istype(data) is int, which keeps rejectingboolvalues such asperiod: true.is_instance_ofis unchanged, sincetest_type_utils.pyasserts that it rejects ints for floats. Theget_attrdocstring, which sayslaunch_yamldoes not apply type coercion, now names this exception.Fixes #1067
Is this user-facing behavior change?
Yes. YAML launch files can give
period,sigterm_timeout,sigkill_timeoutandrespawn_delayas whole numbers such as5. Before this change they needed a decimal point, as in5.0.Did you use Generative AI?
Yes. Claude Code (Claude Opus 5.5) found the bug, wrote the change and the test, and ran the tests below. I reviewed the diff and the test results before opening this pull request.
Additional Information
The new
launch_yaml/test/launch_yaml/test_timer.pyis the YAML version of the XMLtest_timer, withperiod: 5. It fails onrollingwithout the fix.Tested with
launch,launch_xmlandlaunch_yamlfrom source in a Python 3.12 venv:launch_yaml: 30 passed andlaunch_xml: 62 passed, including their flake8, pep257 and copyright tests.ament_xmllintwas not installed.launch: 295 passed.test_mypyandtest_xmllintdid not run withoutament_mypyandament_xmllint. This PR does not change thelaunchpackage.The Python API is unchanged:
TimerAction(period=5)still raises aTypeError.<hr>This is an automatic backport of pull request #1068 done by Mergify.