diff --git a/msgspec/inspect.py b/msgspec/inspect.py index 2f5a804c..b393c035 100644 --- a/msgspec/inspect.py +++ b/msgspec/inspect.py @@ -1002,4 +1002,4 @@ def _translate_inner( ) return out else: - return CustomType(t) + return CustomType(t[args] if args else t) diff --git a/tests/test_inspect.py b/tests/test_inspect.py index 291fd99c..1b10b52a 100644 --- a/tests/test_inspect.py +++ b/tests/test_inspect.py @@ -245,6 +245,13 @@ def test_custom(): assert mi.type_info(complex) == mi.CustomType(complex) +def test_custom_with_args(): + class MyGeneric(Generic[T]): + value: T + + assert mi.type_info(MyGeneric[int]) == mi.CustomType(MyGeneric[int]) + + @pytest.mark.parametrize( "kw", [{}, dict(min_length=0), dict(max_length=3)],