Repository navigation
fix: validate --timeout as finite and greater than zero - #587
LouisDeconinck wants to merge 1 commit into
Conversation
Add validation to reject non-finite and non-positive timeout values including 0, negative numbers, NaN, and infinities. Use math.isfinite() to check for finite values and require timeout > 0. Add table-driven unit tests covering zero, negative values, NaN, both infinities, non-numeric input, the default, and positive values. Fixes wavefnd#585
|
Thanks for the contribution. The behavior implemented here is correct, and I don't see a functional issue with the timeout validation itself. However, this overlaps with #586, which was opened earlier for the same issue, and I prefer its implementation for a few reasons. In this PR, validation happens after args = parser.parse_args()
import math
if not math.isfinite(args.timeout) or args.timeout <= 0:
parser.error(...)This works, but #586 moves the validation into a dedicated argparse type parser. That keeps parsing and validation together at the CLI boundary and avoids adding validation logic after argument parsing. #586 also makes Additionally, #586 explicitly verifies that an invalid timeout is rejected before compiler discovery ( So this PR is not being rejected because the implementation is incorrect. Both approaches solve the bug, but since the changes overlap, I am going to proceed with #586 as the cleaner and more complete implementation and close this one as a duplicate. Thanks for working on it. |
Add validation to reject non-finite and non-positive timeout values
including 0, negative numbers, NaN, and infinities. Use math.isfinite()
to check for finite values and require timeout > 0.
Changes
Test Results
Fixes #585