# extract_type_var_from_base

> **Function** in `langsmith`

📖 [View in docs](https://reference.langchain.com/python/langsmith/_openapi_client/_utils/_typing/extract_type_var_from_base)

Given a type like `Foo[T]`, returns the generic type variable `T`.

This also handles the case where a concrete subclass is given, e.g.
```py
class MyResponse(Foo[bytes]):
    ...

extract_type_var(MyResponse, bases=(Foo,), index=0) -> bytes
```

And where a generic subclass is given:
```py
_T = TypeVar('_T')
class MyResponse(Foo[_T]):
    ...

extract_type_var(MyResponse[bytes], bases=(Foo,), index=0) -> bytes
```

## Signature

```python
extract_type_var_from_base(
    typ: type,
    *,
    generic_bases: tuple[type, ...],
    index: int,
    failure_message: str | None = None,
) -> type
```

---

[View source on GitHub](https://github.com/langchain-ai/langsmith-sdk/blob/d6cd6082f09e7826a2d6afe444ae6119e61b82a6/python/langsmith/_openapi_client/_utils/_typing.py#L91)