Use `aid.uid` over manual `(name, uuid)` tuples

The `.uid`->`.aid` migration (prior commits) re-assembled the
legacy uid pair by hand as `(x.aid.name, x.aid.uuid)`.
`Aid.uid` (`msg/types.py`) is the non-deprecated canonical
property returning exactly that pair, so swap to `x.aid.uid`
everywhere — byte-identical, just DRY + consistent.

Covers the 5 review-flagged source sites (`msg._ops`,
`devx.debug._sync`, `experimental._pubsub`, `_exceptions`)
plus the ~22 unflagged identical sites (`_streaming` f-string
logs + 6 test modules); also tightens the `_exceptions`
`our_uid` annotation to `tuple[str, str]`.

Review: PR #469 (copilot-pull-request-reviewer)
https://github.com/goodboy/tractor/pull/469#pullrequestreview-4575979601

(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
wkt/rm_test_warnings
Gud Boi 2026-06-27 21:38:30 -04:00
parent 3e04968e79
commit bffeba952a
11 changed files with 28 additions and 28 deletions

View File

@ -123,10 +123,10 @@ def test_register_duplicate_name(
'`wait_for_actor` returned'
)
assert (
(portal.channel.aid.name, portal.channel.aid.uuid)
portal.channel.aid.uid
in (
(p2.channel.aid.name, p2.channel.aid.uuid),
(p1.channel.aid.name, p1.channel.aid.uuid),
p2.channel.aid.uid,
p1.channel.aid.uid,
)
)
@ -249,11 +249,11 @@ def test_dup_name_cancel_cascade_escalates_to_hard_kill(
# have last-wins semantics under same-name).
async with tractor.wait_for_actor('doggy') as portal:
expected_uids = {
(p.channel.aid.name, p.channel.aid.uuid)
p.channel.aid.uid
for p in portals
}
assert (
(portal.channel.aid.name, portal.channel.aid.uuid)
portal.channel.aid.uid
in expected_uids
)

View File

@ -64,7 +64,7 @@ def enc_nsp(obj: Any) -> Any:
)
uid: tuple[str, str]|None = (
None if not actor
else (actor.aid.name, actor.aid.uuid)
else actor.aid.uid
)
print(f'{uid} ENC HOOK')
@ -100,7 +100,7 @@ def dec_nsp(
)
uid: tuple[str, str]|None = (
None if not actor
else (actor.aid.name, actor.aid.uuid)
else actor.aid.uid
)
print(
f'{uid}\n'
@ -426,7 +426,7 @@ async def send_back_values(
'''
_aid = tractor.current_actor().aid
uid: tuple = (_aid.name, _aid.uuid)
uid: tuple = _aid.uid
# init state in sub-actor should be default
chk_codec_applied(

View File

@ -69,7 +69,7 @@ async def subscribe(
new_subs = set(new_subs)
remove = new_subs - _registry.keys()
print(f'setting sub to {new_subs} for {(ctx.chan.aid.name, ctx.chan.aid.uuid)}')
print(f'setting sub to {new_subs} for {ctx.chan.aid.uid}')
# remove old subs
for sub in remove:
@ -85,7 +85,7 @@ async def consumer(
) -> None:
_aid = tractor.current_actor().aid
uid = (_aid.name, _aid.uuid)
uid = _aid.uid
async with tractor.wait_for_actor('publisher') as portal:
async with portal.open_context(subscribe) as (ctx, first):

View File

@ -311,7 +311,7 @@ def test_parent_cancels(
ctx: Context,
) -> None:
actor: Actor = current_actor()
uid: tuple = (actor.aid.name, actor.aid.uuid)
uid: tuple = actor.aid.uid
_ctxc: ContextCancelled|None = None
if (
@ -712,9 +712,9 @@ async def test_parent_exits_ctx_after_child_enters_stream(
assert (
ctxc.canceller
==
(current_actor().aid.name, current_actor().aid.uuid)
current_actor().aid.uid
==
(root.aid.name, root.aid.uuid)
root.aid.uid
)
# channel should still be up
@ -1219,7 +1219,7 @@ def test_maybe_allow_overruns_stream(
if cancel_ctx:
assert isinstance(res, ContextCancelled)
assert tuple(res.canceller) == (current_actor().aid.name, current_actor().aid.uuid)
assert tuple(res.canceller) == current_actor().aid.uid
else:
print(f'RX ROOT SIDE RESULT {res}')

View File

@ -956,7 +956,7 @@ async def manage_file(
'''
tmp_path: Path = Path(tmp_path_str)
tmp_file: Path = tmp_path / f'{" ".join((ctx._actor.aid.name, ctx._actor.aid.uuid))}.file'
tmp_file: Path = tmp_path / f'{" ".join(ctx._actor.aid.uid)}.file'
# create a the tmp file and tell the parent where it's at
assert not tmp_file.is_file()
@ -1180,7 +1180,7 @@ def test_sigint_closes_lifetime_stack(
):
await ctx.wait_for_result()
except tractor.ContextCancelled as ctxc:
assert ctxc.canceller == (ctx.chan.aid.name, ctx.chan.aid.uuid)
assert ctxc.canceller == ctx.chan.aid.uid
raise
except trio.TooSlowError:
@ -1300,7 +1300,7 @@ async def caching_ep(
},
# lock around current actor task access
key=(tractor.current_actor().aid.name, tractor.current_actor().aid.uuid),
key=tractor.current_actor().aid.uid,
) as (cache_hit, (clients, chan)),
):

View File

@ -65,7 +65,7 @@ async def spawn(
assert len(an._children) == 1
assert (
(portal.channel.aid.name, portal.channel.aid.uuid)
portal.channel.aid.uid
in
tractor.current_actor().ipc_server._peers
)

View File

@ -1223,7 +1223,7 @@ def pack_error(
str,
str | tuple[str, str]
] = {}
our_uid: tuple = (current_actor().aid.name, current_actor().aid.uuid)
our_uid: tuple[str, str] = current_actor().aid.uid
if (
isinstance(exc, RemoteActorError)

View File

@ -418,7 +418,7 @@ class MsgStream(trio.abc.Channel):
# it can't traverse the transport.
log.warning(
f'Stream was already destroyed?\n'
f'actor: {(ctx.chan.aid.name, ctx.chan.aid.uuid)}\n'
f'actor: {ctx.chan.aid.uid}\n'
f'ctx id: {ctx.cid}'
)
drained.append(re)
@ -823,7 +823,7 @@ async def open_stream_from_ctx(
except KeyError:
log.warning(
f'Stream was already destroyed?\n'
f'actor: {(ctx.chan.aid.name, ctx.chan.aid.uuid)}\n'
f'actor: {ctx.chan.aid.uid}\n'
f'ctx id: {ctx.cid}'
)

View File

@ -92,11 +92,11 @@ async def maybe_wait_for_debugger(
# tearing down.
ctx_in_debug: Context|None = Lock.ctx_in_debug
in_debug: tuple[str, str]|None = (
(ctx_in_debug.chan.aid.name, ctx_in_debug.chan.aid.uuid)
ctx_in_debug.chan.aid.uid
if ctx_in_debug
else None
)
if in_debug == (current_actor().aid.name, current_actor().aid.uuid):
if in_debug == current_actor().aid.uid:
log.debug(
msg
+

View File

@ -129,7 +129,7 @@ def modify_subs(
Effectively a symbol subscription api.
"""
log.info(f"{(ctx.chan.aid.name, ctx.chan.aid.uuid)} changed subscription to {topics}")
log.info(f"{ctx.chan.aid.uid} changed subscription to {topics}")
# update map from each symbol to requesting client's chan
for topic in topics:

View File

@ -345,9 +345,9 @@ class PldRx(Struct):
exc=mte,
cid=msg.cid,
src_uid=(
(ipc.chan.aid.name, ipc.chan.aid.uuid)
ipc.chan.aid.uid
if not is_started_send_side
else (ipc._actor.aid.name, ipc._actor.aid.uuid)
else ipc._actor.aid.uid
),
)
mte._ipc_msg = err_msg
@ -711,7 +711,7 @@ async def drain_to_final_msg(
'Cancelling `MsgStream` drain since '
f'{reason}\n'
f'\n'
f'<= {(ctx.chan.aid.name, ctx.chan.aid.uuid)}\n'
f'<= {ctx.chan.aid.uid}\n'
f' |_{ctx._nsf}()\n'
f'\n'
f'=> {ctx._task}\n'
@ -726,7 +726,7 @@ async def drain_to_final_msg(
else:
report: str = (
'Ignoring "yield" msg during `ctx.result()` drain..\n'
f'<= {(ctx.chan.aid.name, ctx.chan.aid.uuid)}\n'
f'<= {ctx.chan.aid.uid}\n'
f' |_{ctx._nsf}()\n\n'
f'=> {ctx._task}\n'
f' |_{ctx._stream}\n\n'