From 179d7d2b04358f1edfec332bbd6994a93239a431 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 20 Feb 2024 15:28:11 -0500 Subject: [PATCH] Add `NamespacePath._ns` todo for `self:` support --- tractor/msg/ptr.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tractor/msg/ptr.py b/tractor/msg/ptr.py index 550626a..87d7bf2 100644 --- a/tractor/msg/ptr.py +++ b/tractor/msg/ptr.py @@ -58,6 +58,11 @@ class NamespacePath(str): ''' _ref: object | type | None = None + # TODO: support providing the ns instance in + # order to support 'self.` style to make + # `Portal.run_from_ns()` work! + # _ns: ModuleType|type|None = None + def load_ref(self) -> object | type: if self._ref is None: self._ref = resolve_name(self) @@ -100,5 +105,13 @@ class NamespacePath(str): fqnp: tuple[str, str] = cls._mk_fqnp(ref) return cls(':'.join(fqnp)) - def to_tuple(self) -> tuple[str, str]: - return self._mk_fqnp(self.load_ref()) + def to_tuple( + self, + + # TODO: could this work re `self:` case from above? + # load_ref: bool = True, + + ) -> tuple[str, str]: + return self._mk_fqnp( + self.load_ref() + )