Metadata-Version: 2.1
Name: spork
Version: 1.1.2
Project-URL: Documentation, https://github.com/rgbkrk/spork#readme
Project-URL: Issues, https://github.com/rgbkrk/spork/issues
Project-URL: Source, https://github.com/rgbkrk/spork
Author-email: Kyle Kelley <rgbkrk@gmail.com>
License-Expression: MIT
License-File: LICENSE.txt
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.9
Requires-Dist: ipython
Requires-Dist: pydantic
Requires-Dist: typing-extensions
Description-Content-Type: text/markdown

# spork

[![PyPI - Version](https://img.shields.io/pypi/v/spork.svg)](https://pypi.org/project/spork)

[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/spork.svg)](https://pypi.org/project/spork)

Exposing simple ways to render pydantic models in notebooks and other interactive computing environments.

----

**Table of Contents**

- [Installation](#installation)
- [Background](#background)
- [License](#license)

----

## Installation

```console
pip install spork
```

## Background

I created this module because I wanted a simple way to describe how to render pydantic models, especially when streaming in data to update a model. Wouldn't it be nice to see a visual display of the model as it's being updated?

To explore this space a bit, I've created a `View` and an `AutoView`. This lets you update fields and have them update within the notebook.

## Usage

You can use existing pydantic models or create new ones by inheriting from `AutoView`:

```python
from spork import AutoView
from pydantic import BaseModel

class Record(BaseModel):
    name: str
    age: int

class RecordView(Record, AutoView):
    def render(self):
        return f"<b>{self.name}</b> is {self.age} years old."


rv = RecordView(name="Kyle", age=35)
rv.display()
```

When using an `AutoView`, you can update the fields and the view will update wherever you ran `.display()`

```python
rv.age = 101
```


## License

`spork` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
