Skip to main content

Python package to convert python dictionaries into other language types (Currently Typescript).

Project description

Object Converter

Repository to convert Python dictionaries to Typescript Types. Input any full python dictionary, and receive as output a fully formatted and TypeScript type for that dictionary!

Installation

You can find the project on PyPi here. To install, execute the below.

pip install type_gen_dict

Example

    import type_gen_dict as tg
    generator = tg.TypeGenerator()
    sample = {"1": "hello!", "2": 10, "3": "10/29/22", "4": True, "5": [1, "hi", False], "6": None,
              "7": {"8": 1, "9": 2, "10": {"11": True, "12": {"13": None}}}}
    generator.convert(sample, 'ts', verbose=True)

Output:

type ABC = {
  1: string;
  2: number;
  3: string;
  4: boolean;
  5: any[];
  6: null;
  7: {
    8: number;
    9: number;
    10: {
      11: boolean;
      12: {
        13: null;
      }
    }
  }
}

Deploying to Pip

  1. python3 -m build
  2. python3 -m pip install --upgrade twine
  3. python3 -m twine upload --repository pypi dist/*

TODOs

  • Deploy to PyPi!
  • Handle the following types:
    • Tuples
    • List typing (not just any[])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

type_gen_dict-0.0.1.tar.gz (7.1 MB view hashes)

Uploaded Source

Built Distribution

type_gen_dict-0.0.1-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page