ts2py


Namets2py JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/thelicato/ts2py
SummaryPython-Interoperability for Typescript-Interfaces
upload_time2023-01-17 21:30:45
maintainer
docs_urlNone
authorAngelo Delicato
requires_python>=3.10,<4.0
licenseApache-2.0
keywords typescript to python converter typescript interface python typeddict
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ts2py

![](https://img.shields.io/pypi/v/ts2py)
![](https://img.shields.io/pypi/status/ts2py)
![](https://img.shields.io/pypi/pyversions/ts2py)
![](https://img.shields.io/pypi/l/ts2py)

Python-interoperability for Typescript-Interfaces.
Transpiles TypeScript-Interface-definitions to Python TypedDicts

## What is this
This repo is born as a fork of [ts2python](https://github.com/jecki/ts2python) written by Eckhart Arnold <arnold@badw.de>, Bavarian Academy of Sciences and Humanities. The reason behind this fork was that I needed a **simpler** way to quickly convert *TypeScript* interfaces to Python *TypedDict*. Once I started looking into the initial code I decided to change (and remove) a lot of stuff.
I also managed to split the code in multiple files and added [Typer](https://typer.tiangolo.com/) to create a beautiful CLI. The initial project should be much more powerful and should also have **support for run-time type-checking of JSON-data**.

## Purpose
Nowadays **a lot** of applications are created with TypeScript. To enable a much better way of developing when dealing with Python backend it could be useful to quickly convert [Typescript-Interfaces](https://www.typescriptlang.org/docs/handbook/2/objects.html) into Python [TypedDicts](https://www.python.org/dev/peps/pep-0589/). In order to enable structural validation on the Python-side, ts2py transpiles the typescript-interface definitions to Python-data structure definitions.

## Installation

``ts2py`` can be installed from the command line with the command:
```
pip install ts2py
```

ts2py requires the parsing-expression-grammar-framework [DHParser](https://gitlab.lrz.de/badw-it/DHParser) which will automatically be installed as a dependency by the `pip`-command. ts2py requires at least Python Version 3.10 to run. However, the Python-code it produces is backwards compatible down to Python 3.6 thanks to the [typing extensions](https://pypi.org/project/typing-extensions/).

## Usage

In order to generate TypedDict-classes from Typescript-Interfaces, run `ts2py` on the Typescript-Interface definitions:
```
ts2py interfaces.ts
```
This generates a ``.py`` file in same directory as the source file that contains the TypedDict-classes and can simpy be imported in Python-Code:
```python
from interfaces import *
```

## License and Source Code

``ts2py`` is open source software under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0)

The complete source-code of ts2py can be downloaded from the [its git-repository](https://github.com/thelicato/ts2py).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/thelicato/ts2py",
    "name": "ts2py",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "Typescript to Python converter,Typescript Interface,Python TypedDict",
    "author": "Angelo Delicato",
    "author_email": "thelicato@duck.com",
    "download_url": "https://files.pythonhosted.org/packages/b0/8d/64e4ee354ba87fa9a8b843555c356f5dbd9636d8cf06d15ce031024214b3/ts2py-0.0.2.tar.gz",
    "platform": null,
    "description": "# ts2py\n\n![](https://img.shields.io/pypi/v/ts2py)\n![](https://img.shields.io/pypi/status/ts2py)\n![](https://img.shields.io/pypi/pyversions/ts2py)\n![](https://img.shields.io/pypi/l/ts2py)\n\nPython-interoperability for Typescript-Interfaces.\nTranspiles TypeScript-Interface-definitions to Python TypedDicts\n\n## What is this\nThis repo is born as a fork of [ts2python](https://github.com/jecki/ts2python) written by Eckhart Arnold <arnold@badw.de>, Bavarian Academy of Sciences and Humanities. The reason behind this fork was that I needed a **simpler** way to quickly convert *TypeScript* interfaces to Python *TypedDict*. Once I started looking into the initial code I decided to change (and remove) a lot of stuff.\nI also managed to split the code in multiple files and added [Typer](https://typer.tiangolo.com/) to create a beautiful CLI. The initial project should be much more powerful and should also have **support for run-time type-checking of JSON-data**.\n\n## Purpose\nNowadays **a lot** of applications are created with TypeScript. To enable a much better way of developing when dealing with Python backend it could be useful to quickly convert [Typescript-Interfaces](https://www.typescriptlang.org/docs/handbook/2/objects.html) into Python [TypedDicts](https://www.python.org/dev/peps/pep-0589/). In order to enable structural validation on the Python-side, ts2py transpiles the typescript-interface definitions to Python-data structure definitions.\n\n## Installation\n\n``ts2py`` can be installed from the command line with the command:\n```\npip install ts2py\n```\n\nts2py requires the parsing-expression-grammar-framework [DHParser](https://gitlab.lrz.de/badw-it/DHParser) which will automatically be installed as a dependency by the `pip`-command. ts2py requires at least Python Version 3.10 to run. However, the Python-code it produces is backwards compatible down to Python 3.6 thanks to the [typing extensions](https://pypi.org/project/typing-extensions/).\n\n## Usage\n\nIn order to generate TypedDict-classes from Typescript-Interfaces, run `ts2py` on the Typescript-Interface definitions:\n```\nts2py interfaces.ts\n```\nThis generates a ``.py`` file in same directory as the source file that contains the TypedDict-classes and can simpy be imported in Python-Code:\n```python\nfrom interfaces import *\n```\n\n## License and Source Code\n\n``ts2py`` is open source software under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0)\n\nThe complete source-code of ts2py can be downloaded from the [its git-repository](https://github.com/thelicato/ts2py).\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Python-Interoperability for Typescript-Interfaces",
    "version": "0.0.2",
    "split_keywords": [
        "typescript to python converter",
        "typescript interface",
        "python typeddict"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4fad1ddf7d64f63ca7f7ca271f1e60a8e05b5cee708bd586847afe110116c817",
                "md5": "1b893fb7eb327b6ff716ddffbd35f872",
                "sha256": "4c71bc44cb3c23bb610f207bdc0f88dcaf1026fab90f30d688ac92608e9f934f"
            },
            "downloads": -1,
            "filename": "ts2py-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1b893fb7eb327b6ff716ddffbd35f872",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 25982,
            "upload_time": "2023-01-17T21:30:43",
            "upload_time_iso_8601": "2023-01-17T21:30:43.996236Z",
            "url": "https://files.pythonhosted.org/packages/4f/ad/1ddf7d64f63ca7f7ca271f1e60a8e05b5cee708bd586847afe110116c817/ts2py-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b08d64e4ee354ba87fa9a8b843555c356f5dbd9636d8cf06d15ce031024214b3",
                "md5": "745ba9198a4698520256bcd62e19a9dd",
                "sha256": "b3d447287954beca56b4609c7065d3e6b1dc1782a43f662519872fab93f08091"
            },
            "downloads": -1,
            "filename": "ts2py-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "745ba9198a4698520256bcd62e19a9dd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 23645,
            "upload_time": "2023-01-17T21:30:45",
            "upload_time_iso_8601": "2023-01-17T21:30:45.628731Z",
            "url": "https://files.pythonhosted.org/packages/b0/8d/64e4ee354ba87fa9a8b843555c356f5dbd9636d8cf06d15ce031024214b3/ts2py-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-17 21:30:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "thelicato",
    "github_project": "ts2py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ts2py"
}
        
Elapsed time: 0.03707s