Fix six spots where a comment was standing in for clearer code #106
Loading…
Reference in a new issue
No description provided.
Delete branch "chore/fix-comment-smells"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Six small fixes, one commit each, all behaviour-preserving:
CampervanNodeEntity.__init__setsnodeand device info directly instead of routing throughasync_redescribed'sgetattrguard.UpdaterClient._request'spatienceparameter is renamedclient_timeout.discovery.py's_askand_judge_what_arrivedshare a new_finish()for the clear-then-notify step.traffic.py'sasync_handle_frameusesreadings.routed()instead of re-implementing the reserved-source check.traffic.py'sBUCKETSbecomesCLOSED_BUCKETS, dropping the+1docstring.platforms.py's twofollow_the_inventoryclosures share a newready_to_name()predicate.Each commit deletes the comment that was explaining the awkwardness it fixes.
tools/checkpasses; existing tests are the gate for behaviour.Checked all six commits against the pre-refactor behaviour. No bugs found.
Specifically on discovery.py (commit 3): the
_finish()extraction is safe._ask()'s new call to_finish()now clearsself._wait = None, which the old code never did there — but_ask()'s task is only ever created byasync_scan(), which calls_stop_waiting()(and hence sets_wait = None) immediately before creating it, andwaiting/scanningguards keep_wait_for_the_rest()from setting a new one while_ask()runs. So_waitis always alreadyNonefor the whole lifetime of_ask(), and adding the clear there is a genuine no-op. Theshortbranch in_judge_what_arrivedcorrectly keeps its inline clear-without-notify instead of routing through_finish(), avoiding the spurioussettled=Trueblip you flagged — confirmed against706e7bb^.Two purely cosmetic, non-blocking observations:
async_handle_frame: whenrouted()returnsNone(reserved/broadcast source), the code now decodesmessage.arbitration_ida second time to getidentifierfor the failure-path log line, where the old code decoded once up front. Harmless (rare path), just a duplicate call — not worth blocking on._finish()'s merged comment drops the old "whatever could not be read has just been asked about" rationale for clearing_lost_a_frame. Reasonable to drop since it only made sense in_ask()'s context (a fresh query was just sent) and would have been misleading if kept verbatim for the_judge_what_arrivedcaller — no action needed, just flagging that the specific "why" for that field is no longer spelled out anywhere.Everything else —
entity.py's direct__init__assignment,firmware.py'sclient_timeoutrename,traffic.py'sCLOSED_BUCKETSarithmetic (3closed + 1 in-flight = samemaxlen=4as before), andplatforms.py'sready_to_namepredicate — is behaviourally equivalent to what it replaced, and the spec citation removed fromasync_setup_node_entities's comment (section 8.1) is still carried by the module docstring at the top of platforms.py.