Skip to content

Commit c6b7e69

Browse files
committed
refactor: use UnifiedParameterAnalyzer as sole parameter entrypoint
ObjectState._analyze_parameters now delegates exclusively to python_introspect.UnifiedParameterAnalyzer and removes dead fallback paths.
1 parent a8c444e commit c6b7e69

1 file changed

Lines changed: 4 additions & 22 deletions

File tree

src/objectstate/object_state.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,15 +1794,13 @@ def _analyze_parameters(self, obj: Any, exclude_params: Optional[List[str]] = No
17941794
exclude_params = exclude_params or []
17951795
result = {}
17961796

1797-
obj_type = obj if isinstance(obj, type) else type(obj)
1798-
1799-
# Use the richer UnifiedParameterAnalyzer. This extracts docstring-derived
1800-
# `description` for dataclass fields and other objects.
1801-
#
18021797
# NOTE: python_introspect is a required dependency in OpenHCS; fail loud if missing.
1798+
# UnifiedParameterAnalyzer is responsible for correctness guarantees:
1799+
# - defaults come from type/signature (never from instance)
1800+
# - current instance values are accessed in a lazy-safe way (if needed)
18031801
from python_introspect import UnifiedParameterAnalyzer
18041802

1805-
ua_info = UnifiedParameterAnalyzer.analyze(obj, exclude_params=exclude_params or [])
1803+
ua_info = UnifiedParameterAnalyzer.analyze(obj, exclude_params=exclude_params)
18061804
for name, info in ua_info.items():
18071805
if name in exclude_params:
18081806
continue
@@ -1813,22 +1811,6 @@ def _analyze_parameters(self, obj: Any, exclude_params: Optional[List[str]] = No
18131811
)
18141812
return result
18151813

1816-
# Prefer python_introspect for plain callables (functions/methods) to
1817-
# preserve full signature info (defaults, doc-derived types, descriptions).
1818-
if inspect.isfunction(obj) or inspect.ismethod(obj) or (callable(obj) and not inspect.isclass(obj)):
1819-
from python_introspect import SignatureAnalyzer
1820-
1821-
sig_info = SignatureAnalyzer.analyze(obj)
1822-
for name, info in sig_info.items():
1823-
if name in exclude_params:
1824-
continue
1825-
result[name] = SimpleNamespace(
1826-
param_type=getattr(info, "param_type", Any),
1827-
default_value=getattr(info, "default_value", None),
1828-
description=getattr(info, "description", None)
1829-
)
1830-
return result
1831-
18321814
if is_dataclass(obj_type):
18331815
# Dataclass: use fields()
18341816
for field in fields(obj_type):

0 commit comments

Comments
 (0)