Skip to content

Commit

Permalink
✨ feat(flags): add flag FilterRepr (#46)
Browse files Browse the repository at this point in the history
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
  • Loading branch information
nstarman authored Dec 6, 2024
1 parent 4efc995 commit 84a73d7
Show file tree
Hide file tree
Showing 4 changed files with 361 additions and 16 deletions.
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,14 @@ consideration by the functions in `dataclassish`.
```pycon
>>> from dataclassish import flags
>>> flags.__all__
['FlagConstructionError', 'AbstractFlag', 'NoFlag']
['FlagConstructionError', 'AbstractFlag', 'NoFlag', 'FilterRepr']

```

Where `AbstractFlag` is the base class for flags, and `NoFlag` is a flag that
does nothing. `FlagConstructionError` is an error that is raised when a flag is
constructed incorrectly.
Where `AbstractFlag` is the base class for flags, `NoFlag` is a flag that does
nothing, and `FilterRepr` will filter out any fields with `repr=True`.
`FlagConstructionError` is an error that is raised when a flag is constructed
incorrectly.

As a quick example, we'll show how to use `NoFlag`.

Expand All @@ -421,6 +422,21 @@ As a quick example, we'll show how to use `NoFlag`.

```

As another example, we'll show how to use `FilterRepr`.

```pycon
>>> from dataclasses import field
>>> @dataclass
... class Point:
... x: float
... y: float = field(repr=False)
>>> obj = Point(1.0, 2.0)

>>> field_keys(flags.FilterRepr, obj)
('x',)

```

## Citation

[![DOI][zenodo-badge]][zenodo-link]
Expand Down Expand Up @@ -448,8 +464,6 @@ We welcome contributions!
[pypi-link]: https://pypi.org/project/dataclassish/
[pypi-platforms]: https://img.shields.io/pypi/pyversions/dataclassish
[pypi-version]: https://img.shields.io/pypi/v/dataclassish
[rtd-badge]: https://readthedocs.org/projects/dataclassish/badge/?version=latest
[rtd-link]: https://dataclassish.readthedocs.io/en/latest/?badge=latest
[ruff-badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json
[ruff-link]: https://docs.astral.sh/ruff/
[spec0-badge]: https://img.shields.io/badge/SPEC-0-green?labelColor=%23004811&color=%235CA038
Expand Down
Loading

0 comments on commit 84a73d7

Please sign in to comment.