# libtmux._internal.dataclasses.SkipDefaultFieldsReprMixin

- **Module:** libtmux._internal.dataclasses
- **Package:** libtmux
- **Language:** Python
- **Kind:** class
- **Source:** https://github.com/tmux-python/libtmux/blob/38e368c11117fb4aeb2f082d552cd4f210eae06a/src/libtmux/_internal/dataclasses.py#L18
- **Page:** https://libtmux.org/en/py/stable/reference/libtmux-_internal-dataclasses-skipdefaultfieldsreprmixin/

Skip default fields in :func:`~dataclasses.dataclass` object representation.

### Notes

Credit: Pietro Oldrati, 2022-05-08, Unilicense

https://stackoverflow.com/a/72161437/1396928

## Examples

```python
>>> @dataclasses.dataclass()
... class Item:
...     name: str
...     unit_price: float = 1.00
...     quantity_on_hand: int = 0
...
```

```python
>>> @dataclasses.dataclass(repr=False)
... class ItemWithMixin(SkipDefaultFieldsReprMixin):
...     name: str
...     unit_price: float = 1.00
...     quantity_on_hand: int = 0
...
```

```python
>>> Item('Test')
Item(name='Test', unit_price=1.0, quantity_on_hand=0)
```

```python
>>> ItemWithMixin('Test')
ItemWithMixin(name=Test)
```

```python
>>> Item('Test', quantity_on_hand=2)
Item(name='Test', unit_price=1.0, quantity_on_hand=2)
```

```python
>>> ItemWithMixin('Test', quantity_on_hand=2)
ItemWithMixin(name=Test, quantity_on_hand=2)
```

If you want to copy/paste the :meth:`~.__repr__()` directly, you can omit the ``repr=False``:

```python
>>> @dataclasses.dataclass
... class ItemWithMixin(SkipDefaultFieldsReprMixin):
...     name: str
...     unit_price: float = 1.00
...     quantity_on_hand: int = 0
...     __repr__ = SkipDefaultFieldsReprMixin.__repr__
...
```

```python
>>> ItemWithMixin('Test')
ItemWithMixin(name=Test)
```

```python
>>> ItemWithMixin('Test', unit_price=2.00)
ItemWithMixin(name=Test, unit_price=2.0)
```

```python
>>> item = ItemWithMixin('Test')
>>> item.unit_price = 2.05
```

```python
>>> item
ItemWithMixin(name=Test, unit_price=2.05)
```

## Members

### Other members

- [`__repr__`](/en/py/stable/reference/libtmux-_internal-dataclasses-skipdefaultfieldsreprmixin-__repr__/) (method): Omit default fields in object representation.
