thrift2pyi


Namethrift2pyi JSON
Version 1.0.5 PyPI version JSON
download
home_page
Summaryconvert thrift to pyi
upload_time2023-07-24 03:31:52
maintainer
docs_urlNone
authoryanweizhi
requires_python>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
license
keywords thrift2pyi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # thrift2pyi
convert thrift to pyi

# How to use
pip install thrift2pyi

thrift2pyi tests/example.thrift

thrift2pyi tests/src/example.thrift  -p tests/src -o tests/dest

See dir "tests" for details. 

# Example
```thrift
namespace py example

include "a/a.thrift"


const string A = "1";
const i32 B = 1;
const list<i32> C = [];
const list<i32> D = [1,2];
const map<i32,string> E = {};
const double F = 1.1;

struct Example {
    1: map<map<a.A,a.A>, a.A> A
    2: optional i16 B
    3: i32 C
    4: i64 D
    5: bool E = true
    6: byte F
    7: double G = 0.1
    8: string H = "hello"
    9: a.A I
    10: map<a.A, map<a.A,a.A>> J
    11: map<a.A, a.A> K
    12: map<string, bool> L = {}
    13: map<string, list<map<string, a.A>>> M
    14: list<a.A> N
    15: list<string> O
    16: set<i16> P
    17: list<map<string, a.A>> Q
    18: binary R
}

enum ExampleEnum {
    A = 0
    B = 1
    C = 2
}


enum ErrCode {
    ERR_SUCCESS = 0
    ERR_REQ_PARAM_INVALID  = 4000
    ERR_UNKNOWN = 5000
    ERR_SYSTEM_INNER_EXCEPTION = 5001
    ERR_LIMIT_EXCEEDED = 5002
}

union ExampleUnion {
    1: i32 A = 1
}

exception ByteException {
    1: i32 ErrorCode = 0,
}

service ExampleService {
    Example Get(1: a.A rq, 2: i64 xx)
    i16 Pull(1: string name = "", 2: map<string,string> xxx) throws (1: ByteException exc)
    void Test()
}

```

generated by thrift2pyi

```python
# coding:utf-8
from typing import List, Set, Dict
from .a import a_thrift as a
from thriftpy2.thrift import TException
from enum import Enum

A = '1'
B = 1
C = []
D = [1, 2]
E = {}
F = 1.1


# noinspection PyPep8Naming, PyShadowingNames
class ExampleEnum(Enum):
    A = 0
    B = 1
    C = 2


# noinspection PyPep8Naming, PyShadowingNames
class ErrCode(Enum):
    ERR_SUCCESS = 0
    ERR_REQ_PARAM_INVALID = 4000
    ERR_UNKNOWN = 5000
    ERR_SYSTEM_INNER_EXCEPTION = 5001
    ERR_LIMIT_EXCEEDED = 5002


# noinspection PyPep8Naming, PyShadowingNames
class Example(object):
    A: Dict[Dict[a.A, a.A], a.A]
    B: int
    C: int
    D: int
    E: bool
    F: int
    G: float
    H: str
    I: a.A
    J: Dict[a.A, Dict[a.A, a.A]]
    K: Dict[a.A, a.A]
    L: Dict[str, bool]
    M: Dict[str, List[Dict[str, a.A]]]
    N: List[a.A]
    O: List[str]
    P: Set[int]
    Q: List[Dict[str, a.A]]

    def __init__(self,
                 A: Dict[Dict[a.A, a.A], a.A] = None,
                 B: int = None,
                 C: int = None,
                 D: int = None,
                 E: bool = True,
                 F: int = None,
                 G: float = 0.1,
                 H: str = 'hello',
                 I: a.A = None,
                 J: Dict[a.A, Dict[a.A, a.A]] = None,
                 K: Dict[a.A, a.A] = None,
                 L: Dict[str, bool] = {},
                 M: Dict[str, List[Dict[str, a.A]]] = None,
                 N: List[a.A] = None,
                 O: List[str] = None,
                 P: Set[int] = None,
                 Q: List[Dict[str, a.A]] = None) -> None:
        ...


# noinspection PyPep8Naming, PyShadowingNames
class ByteException(TException):
    ErrorCode: int

    def __init__(self, ErrorCode: int = 0) -> None:
        ...


# noinspection PyPep8Naming, PyShadowingNames
class ExampleService(object):
    def Get(self, rq: a.A = None, xx: int = None) -> Example:
        ...

    def Pull(self, name: str = '', xxx: Dict[str, str] = None) -> int:
        ...

    def Test(self, ) -> None:
        ...

```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "thrift2pyi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
    "maintainer_email": "",
    "keywords": "thrift2pyi",
    "author": "yanweizhi",
    "author_email": "yanweizhi <yanweizhi@bytedance.com>",
    "download_url": "https://files.pythonhosted.org/packages/a4/ac/2dccc9dc06a9ab1e5aedd18845d4cad49b5a3dea1099d90aa484a3ea4953/thrift2pyi-1.0.5.tar.gz",
    "platform": null,
    "description": "# thrift2pyi\nconvert thrift to pyi\n\n# How to use\npip install thrift2pyi\n\nthrift2pyi tests/example.thrift\n\nthrift2pyi tests/src/example.thrift  -p tests/src -o tests/dest\n\nSee dir \"tests\" for details. \n\n# Example\n```thrift\nnamespace py example\n\ninclude \"a/a.thrift\"\n\n\nconst string A = \"1\";\nconst i32 B = 1;\nconst list<i32> C = [];\nconst list<i32> D = [1,2];\nconst map<i32,string> E = {};\nconst double F = 1.1;\n\nstruct Example {\n    1: map<map<a.A,a.A>, a.A> A\n    2: optional i16 B\n    3: i32 C\n    4: i64 D\n    5: bool E = true\n    6: byte F\n    7: double G = 0.1\n    8: string H = \"hello\"\n    9: a.A I\n    10: map<a.A, map<a.A,a.A>> J\n    11: map<a.A, a.A> K\n    12: map<string, bool> L = {}\n    13: map<string, list<map<string, a.A>>> M\n    14: list<a.A> N\n    15: list<string> O\n    16: set<i16> P\n    17: list<map<string, a.A>> Q\n    18: binary R\n}\n\nenum ExampleEnum {\n    A = 0\n    B = 1\n    C = 2\n}\n\n\nenum ErrCode {\n    ERR_SUCCESS = 0\n    ERR_REQ_PARAM_INVALID  = 4000\n    ERR_UNKNOWN = 5000\n    ERR_SYSTEM_INNER_EXCEPTION = 5001\n    ERR_LIMIT_EXCEEDED = 5002\n}\n\nunion ExampleUnion {\n    1: i32 A = 1\n}\n\nexception ByteException {\n    1: i32 ErrorCode = 0,\n}\n\nservice ExampleService {\n    Example Get(1: a.A rq, 2: i64 xx)\n    i16 Pull(1: string name = \"\", 2: map<string,string> xxx) throws (1: ByteException exc)\n    void Test()\n}\n\n```\n\ngenerated by thrift2pyi\n\n```python\n# coding:utf-8\nfrom typing import List, Set, Dict\nfrom .a import a_thrift as a\nfrom thriftpy2.thrift import TException\nfrom enum import Enum\n\nA = '1'\nB = 1\nC = []\nD = [1, 2]\nE = {}\nF = 1.1\n\n\n# noinspection PyPep8Naming, PyShadowingNames\nclass ExampleEnum(Enum):\n    A = 0\n    B = 1\n    C = 2\n\n\n# noinspection PyPep8Naming, PyShadowingNames\nclass ErrCode(Enum):\n    ERR_SUCCESS = 0\n    ERR_REQ_PARAM_INVALID = 4000\n    ERR_UNKNOWN = 5000\n    ERR_SYSTEM_INNER_EXCEPTION = 5001\n    ERR_LIMIT_EXCEEDED = 5002\n\n\n# noinspection PyPep8Naming, PyShadowingNames\nclass Example(object):\n    A: Dict[Dict[a.A, a.A], a.A]\n    B: int\n    C: int\n    D: int\n    E: bool\n    F: int\n    G: float\n    H: str\n    I: a.A\n    J: Dict[a.A, Dict[a.A, a.A]]\n    K: Dict[a.A, a.A]\n    L: Dict[str, bool]\n    M: Dict[str, List[Dict[str, a.A]]]\n    N: List[a.A]\n    O: List[str]\n    P: Set[int]\n    Q: List[Dict[str, a.A]]\n\n    def __init__(self,\n                 A: Dict[Dict[a.A, a.A], a.A] = None,\n                 B: int = None,\n                 C: int = None,\n                 D: int = None,\n                 E: bool = True,\n                 F: int = None,\n                 G: float = 0.1,\n                 H: str = 'hello',\n                 I: a.A = None,\n                 J: Dict[a.A, Dict[a.A, a.A]] = None,\n                 K: Dict[a.A, a.A] = None,\n                 L: Dict[str, bool] = {},\n                 M: Dict[str, List[Dict[str, a.A]]] = None,\n                 N: List[a.A] = None,\n                 O: List[str] = None,\n                 P: Set[int] = None,\n                 Q: List[Dict[str, a.A]] = None) -> None:\n        ...\n\n\n# noinspection PyPep8Naming, PyShadowingNames\nclass ByteException(TException):\n    ErrorCode: int\n\n    def __init__(self, ErrorCode: int = 0) -> None:\n        ...\n\n\n# noinspection PyPep8Naming, PyShadowingNames\nclass ExampleService(object):\n    def Get(self, rq: a.A = None, xx: int = None) -> Example:\n        ...\n\n    def Pull(self, name: str = '', xxx: Dict[str, str] = None) -> int:\n        ...\n\n    def Test(self, ) -> None:\n        ...\n\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "convert thrift to pyi",
    "version": "1.0.5",
    "project_urls": {
        "Bug Tracker": "https://github.com/pypa/sampleproject/issues",
        "Homepage": "https://github.com/pypa/sampleproject"
    },
    "split_keywords": [
        "thrift2pyi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "432da5cc797d1d8a4bb9244ad0733bb7bcbcfc366dec94c2e8a7f738977bf340",
                "md5": "13cbaf0a16487be6cfce063542324586",
                "sha256": "d112b2d32c31195d257a7546474fc0ff7a18e59af2dd6f542651ac12516c16a2"
            },
            "downloads": -1,
            "filename": "thrift2pyi-1.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "13cbaf0a16487be6cfce063542324586",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
            "size": 8952,
            "upload_time": "2023-07-24T03:31:49",
            "upload_time_iso_8601": "2023-07-24T03:31:49.849067Z",
            "url": "https://files.pythonhosted.org/packages/43/2d/a5cc797d1d8a4bb9244ad0733bb7bcbcfc366dec94c2e8a7f738977bf340/thrift2pyi-1.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a4ac2dccc9dc06a9ab1e5aedd18845d4cad49b5a3dea1099d90aa484a3ea4953",
                "md5": "2c6d02e5a545e40362e5c1c284ebf8f2",
                "sha256": "9d511eeeacb27da8fa618863c254723638d0d3706e4cd2670c0c1e7d5d5be7af"
            },
            "downloads": -1,
            "filename": "thrift2pyi-1.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "2c6d02e5a545e40362e5c1c284ebf8f2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
            "size": 9270,
            "upload_time": "2023-07-24T03:31:52",
            "upload_time_iso_8601": "2023-07-24T03:31:52.806435Z",
            "url": "https://files.pythonhosted.org/packages/a4/ac/2dccc9dc06a9ab1e5aedd18845d4cad49b5a3dea1099d90aa484a3ea4953/thrift2pyi-1.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-24 03:31:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pypa",
    "github_project": "sampleproject",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "thrift2pyi"
}
        
Elapsed time: 0.26597s