-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't workingruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
If the sleep time is an integer above 2^64 - 1 (18446744073709551615) it will not be caught by ASYNC1116 playground
import trio
async def func():
await trio.sleep(9999999999999999999) # ASYNC116
async def func():
await trio.sleep(10000000000000000000000000000000000e100000000000000000000000000000000) # ASYNC116
async def func():
await trio.sleep(99999999999999999999999999999999.0) # ASYNC116
async def func():
await trio.sleep(18446744073709551615) # ASYNC116
async def func():
await trio.sleep(18446744073709551616) # No error
async def func():
await trio.sleep(99999999999999999999) # No errorI'm not an async user, but this may be worth fixing since my natural amount of 9s for a really big number is just above the limit this rule will detect.
I think the bug comes from here
ruff/crates/ruff_linter/src/rules/flake8_async/rules/long_sleep_not_forever.rs
Lines 103 to 110 in cb512ba
| Number::Int(int_value) => { | |
| let Some(int_value) = int_value.as_u64() else { | |
| return; | |
| }; | |
| if int_value <= one_day_in_secs { | |
| return; | |
| } | |
| } |
If the as_u64 fails, that should mean the number is bigger than a u64, and thus the error should be reported, instead of skipped.
I think floats bypass this issue since they give inf if they are too big.
Version
playground
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingruleImplementing or modifying a lint ruleImplementing or modifying a lint rule