/slow-learner-convert

A library to convert `slow_learner` output to different types

Primary LanguagePythonMIT LicenseMIT

slow-learner-convert

A library to convert slow-learner output to different data model frameworks.

Usage

Following the example provided in the slow-learner announcing post and assuming Release.py is in the current directory, one would generate msgspec structs equivalent to the typing.TypedDict objects in Release.py by executing:

slow-learner-convert --input-file Release.py --output-file Release_msgspec.py --framework msgspec

More specifically, if example.py contains

from typing import TypedDict


class Foo(TypedDict):
    bar: str
	

Baz = TypedDict("Baz", {"qux": int})

then the command line program

slow-learner-convert --input-file example.py --framework attrs

will generate example_attrs.py, containing the following code.

import attrs
from typing import TypedDict


@attrs.define
class Foo:
    bar: str


@attrs.define
class Baz:
    qux: int

Currently four frameworks are supported:

Installation

python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -U pip
python3 -m pip install slow-learner-convert

Development

I used rye (with uv backend) while developing this:

git clone git@github.com:gorkaerana/slow-learner-convert.git
cd slow-learner-convert
rye sync