Skip to main content

slow-learner — python type inference tool

See also: post

A library and CLI to consume a stream of values (for CLI — JSON documents) and generate Python types describing it. Features:

  • recursion into mappings and collections with generic types generation
  • "structured dicts" are turned into TypedDicts by default
  • values with a small set of observed values are turned into Literals

Installation

pip install slow-learner

Usage

As CLI:

slow-learner learn 1.json 2.json 3.json

# to learn the type of list item
slow-learner learn --spread list.json

In Python:

from slow_learner import TypeLearner

tl = TypeLearner(
    max_literal_type_size=5,
    learn_typed_dicts=True,
    max_typed_dict_size=50,
    max_recursive_type_depth=5,
    no_literal_patterns=[r"\.password", r".*secret"],
)

for value in my_values:
    tl.observe(value)

tl.save_type_definition("result.py", "MyType")

Metadata

Release files for slow-learner 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slow-learner 0.1.3
File Size Uploaded Provenance
slow_learner-0.1.3.tar.gz 26.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for slow-learner 0.1.3
File Interpreter ABI Platform
slow_learner-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 51.1 kB

Release files / slow_learner-0.1.3.tar.gz

Download URL slow_learner-0.1.3.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
263b402b878a150c973a0861a85e59bd9eda33be5e519c12cf2512b61817a430
BLAKE2b-256 checksum
How to use checksums
74e015721cca2cdfa1aa5af3de5c75f6f1865dc33b243761cb077cbc1a072964
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Release files / slow_learner-0.1.3-py3-none-any.whl

Download URL slow_learner-0.1.3-py3-none-any.whl
Size 24.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2ea0b07a5712aefe14dd4d411fd82dc2a12ee9489195e0cb028a17df052e31a
BLAKE2b-256 checksum
How to use checksums
6f51b48dfb0eb6dd7fef3a1fcbd1319cd16321201929184362117bddd9ddd701
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Security for slow-learner 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page