Add `NamespacePath._ns` todo for `self:<ns.meth>` support

pre_pretty_struct_dep_commit_b54cb66
Tyler Goodlet 2024-02-20 15:28:11 -05:00
parent 27b750e907
commit 5fa040c7db
1 changed files with 15 additions and 2 deletions

View File

@ -58,6 +58,11 @@ class NamespacePath(str):
'''
_ref: object | type | None = None
# TODO: support providing the ns instance in
# order to support 'self.<meth>` 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:<meth>` case from above?
# load_ref: bool = True,
) -> tuple[str, str]:
return self._mk_fqnp(
self.load_ref()
)