Failing tests that should pass
import pytest
from effectful.internals.unification import nested_type
def test_nested_type_marker_decorator_widens_to_class():
"""MarkDecorator lacks `__qualname__`; `typing.get_overloads` raises
AttributeError instead of widening to `Box(MarkDecorator)`."""
assert nested_type(pytest.mark.parametrize).value is type(pytest.mark.parametrize)
def test_nested_type_method_descriptor_widens_to_class():
"""method_descriptor lacks `__module__`; same shape."""
assert nested_type(dict.get).value is type(dict.get)
def test_nested_type_unresolvable_forward_ref_widens():
"""An Operation whose default carries a stringified annotation that
does not resolve in scope. `inspect.signature` → `__signature__` →
`typing.get_type_hints` raises NameError instead of widening to
`Box(Operation)`."""
def _hidden_module():
class ClientSession:
pass
def real(x: "ClientSession") -> int:
...
return real
from effectful.ops.syntax import defop
op = defop(_hidden_module())
assert nested_type(op).value is type(op)
Invariant being violated
IIUC, and this invariant PR #613,: nested_type is part of the canonicalize-widening family: When introspection cannot construct a more precise TypeExpression, the documented fallback is Box(type(value)), not a raise. The Callable branch in effectful/internals/unification.py currently honors this for ValueError but lets AttributeError/NameError/TypeError from typing.get_overloads and inspect.signature escape.
This affected downstream #670 in trying to create reader tools for similar cases to the above.
Failing tests that should pass
Invariant being violated
IIUC, and this invariant PR #613,:
nested_typeis part of the canonicalize-widening family: When introspection cannot construct a more preciseTypeExpression, the documented fallback isBox(type(value)), not a raise. The Callable branch ineffectful/internals/unification.pycurrently honors this forValueErrorbut letsAttributeError/NameError/TypeErrorfromtyping.get_overloadsandinspect.signatureescape.This affected downstream #670 in trying to create reader tools for similar cases to the above.