# types

Larky module containing functions checking types.

This module defines utility functions to assist in dynamic creation of new types. It also defines names for some object types that are used by the standard Python interpreter, but not exposed as builtins like int or str are. Finally, it provides some additional type-related utility classes and functions that are not fundamental enough to be builtins.

Similar to [types](https://docs.python.org/3/library/types.html).

## types.MethodType(func, instance)

Binds func to the instance class.

## types.is\_bool(v)

Returns True if v is an instance of a bool.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a bool, False otherwise.

## types.is\_bytearray(v)

Returns True if v is an instance of a byte array.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a byte array, False otherwise.

## types.is\_bytelike(v)

Returns True if v is an instance of bytelike: bytes or byte array.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a bytelike, False otherwise.

## types.is\_bytes(v)

Returns True if v is an instance of a bytes.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a bytes, False otherwise.

## types.is\_callable(v)

Returns True if v is an instance of a callable: function or a lambda.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a callable, False otherwise.

## types.is\_dict(v)

Returns True if v is an instance of a dict.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a dict, False otherwise.

## types.is\_float(v)

Returns True if v is an instance of a floating point number.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a floating point number, False otherwise.

## types.is\_function(v)

Returns True if v is an instance of a function.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a function, False otherwise.

## types.is\_int(v)

Returns True if v is an instance of a signed integer.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a signed integer, False otherwise.

## types.is\_iterable(v)

Returns True if v is an instance of a range: tuple, list or range.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a iterable, False otherwise.

## types.is\_lambda(v)

Returns True if v is an instance of a lambda.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a lambda, False otherwise.

## types.is\_list(v)

Returns True if v is an instance of a list.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a list, False otherwise.

## types.is\_mutablestruct(v)

Returns True if v is a mutablestruct created by larky.mutablestruct().

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v was created by larky.mutablestruct(), False otherwise.

## types.is\_none(v)

Returns True if v is an instance of a None.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a None, False otherwise.

## types.is\_range(v)

Returns True if v is an instance of a range.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a range, False otherwise.

## types.is\_set(v)

Returns True if v is a set created by sets.make().

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v was created by sets.make(), False otherwise.

## types.is\_string(v)

Returns True if v is an instance of a string.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a string, False otherwise.

## types.is\_structlike(v)

Returns True if v is an instance of structlike.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a structlike, False otherwise.

## types.is\_subclass(sub\_class, parent\_class)

Returns True if v is a set created by sets.make().

**Parameters:**

* **sub\_class** – the value of class to chech.
* **parent\_class** – the value of a parent class to check inheritance with.

*Returns:* True if sub\_class is inherited from parent\_class, False otherwise.

## types.is\_tuple(v)

Returns True if v is an instance of a tuple.

**Parameters:**

**v** – the value whose type should be checked.

*Returns:* True if v is an instance of a tuple, False otherwise.

## types.new\_class(name, bases=(), kwds=None, exec\_body=None)

Create a class object dynamically using the appropriate metaclass.

```python
class MyStaticClass(object, metaclass=MySimpleMeta):
    pass
```

is equivalent to:

```python
MyStaticClass = types.new_class(
 "MyStaticClass",
 (object,),
 {"metaclass": MyMeta},
 lambda ns: ns
 )
```

## types.prepare\_class(name, bases=(), kwds=None)

Calculates the appropriate metaclass and creates the class namespace. The arguments are the components that make up a class definition header: the class name, the base classes (in order) and the keyword arguments (such as metaclass).

**Parameters:**

* **name** – is the appropriate metaclass.
* **metaclass** – is the appropriate metaclass, namespace is the prepared class namespace and kwds is an updated copy of the passed in.

kwds argument with any ‘metaclass’ entry removed. If no kwds argument is passed in, this will be an empty dict. :param [\*](#id1)kwds: is an updated copy of the passed in kwds argument with any.

*Returns:* (metaclass, namespace, kwds) as a 3-tuple.

## types.resolve\_bases(bases)

Resolve MRO entries dynamically as specified by PEP 560.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.verygoodsecurity.com/vault/developer-tools/larky/library-api/types.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
