Skip to content

Commit 09af7e2

Browse files
committed
Add inspector module
1 parent 7bd0630 commit 09af7e2

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

monic/runtime/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from monic.runtime import arrow
88
from monic.runtime import datetime
9+
from monic.runtime import inspector
910
from monic.runtime import json
1011
from monic.runtime import numpy
1112
from monic.runtime import pandas
@@ -16,6 +17,7 @@
1617
__all__ = [
1718
"arrow",
1819
"datetime",
20+
"inspector",
1921
"json",
2022
"numpy",
2123
"pandas",

monic/runtime/inspector.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Monic Framework
3+
#
4+
# Copyright (c) 2024-2025 Cognica, Inc.
5+
#
6+
7+
import inspect
8+
import types
9+
import typing as t
10+
11+
from monic.expressions.registry import (
12+
NamespaceProxy,
13+
monic_bind_default,
14+
)
15+
16+
17+
@monic_bind_default("inspector.signature")
18+
def inspector_signature(
19+
obj: t.Callable[..., t.Any] | NamespaceProxy | types.ModuleType
20+
) -> str:
21+
if isinstance(obj, (NamespaceProxy, types.ModuleType)):
22+
raise ValueError("Object is not callable.")
23+
24+
if hasattr(obj, "__expressions_name__"):
25+
name = obj.__expressions_name__
26+
else:
27+
name = f"{obj.__module__}.{obj.__name__}"
28+
29+
sig = inspect.signature(obj)
30+
31+
return f"{name}{sig.format()}"
32+
33+
34+
@monic_bind_default("inspector.is_available")
35+
def inspector_is_available() -> bool:
36+
return True

0 commit comments

Comments
 (0)