INNER CODE UNIT · Python

_calling_module

rio-labs/rio · rio/app.py:528

    def _calling_module(self) -> types.ModuleType:
        call_frame = introspection.CallFrame.current()

        while call_frame is not None:
            module_name = call_frame.globals["__name__"]

            if module_name.startswith("rio.") or module_name == "functools":
                call_frame = call_frame.parent
                continue

            return sys.modules[module_name]

        assert False, "Calling module could not be found?!"

    @functools.cached_property
    def _base_dir_for_relative_paths(self) -> Path:
        if self._calling_module.__file__ is None:
            # TODO: What do we do in this case?

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…