Skip to content

Commit

Permalink
Merge branch 'Thriftpy:master' into issue172
Browse files Browse the repository at this point in the history
  • Loading branch information
truebit authored May 26, 2023
2 parents 11c2956 + d48d58c commit b74a8cd
Show file tree
Hide file tree
Showing 65 changed files with 1,421 additions and 866 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest pytest-asyncio cython
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 thriftpy2 --count --select=E9,F63,F7,F82 --show-source --statistics --ignore C901
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 thriftpy2 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --ignore C901
- name: Test with pytest
run: |
pip install -e ".[dev]"
cd tests
pytest
26 changes: 0 additions & 26 deletions .github/workflows/pythonpublish.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ pip-log.txt
*.sw[op]
env/
.vscode/

pyvenv.cfg
share/*
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ python:
- 2.7
- 3.4
- pypy
- pypy3

matrix:
include:
Expand Down
16 changes: 16 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ Changelog

0.4.x
~~~~~
Version 0.4.16
-------------

Released on Nov 15, 2022.

- Fix unexpected binary type id in TBinaryTransport serialization

Version 0.4.15
-------------

Released on Nov 8, 2021.

- Support Apache JSON protocol and binary type
- Replace "yield from" syntax to "await"
- Fix some socket leaking cases in aio support

Version 0.4.14
-------------

Expand Down
2 changes: 2 additions & 0 deletions benchmark/benchmark_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def make_addressbook():
ab = addressbook.AddressBook()
ab.people = {person.name: person}
return ab


ab_encoded = serialize(make_addressbook())


Expand Down
1 change: 1 addition & 0 deletions examples/gunicorn_thrift/ping_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ def ping(self):
print("ping pong!")
return 'pong'


app = TProcessor(pingpong.PingService, Dispatcher())
1 change: 1 addition & 0 deletions examples/gunicorn_thrift/ping_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ def main():
pong = c.ping()
print(pong)


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion examples/multiplexer/multiplexed_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from thriftpy2.protocol import (
TBinaryProtocolFactory,
TMultiplexedProtocolFactory
)
)

dd_thrift = thriftpy2.load("dingdong.thrift", module_name="dd_thrift")
pp_thrift = thriftpy2.load("pingpong.thrift", module_name="pp_thrift")
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/tutorial_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from thriftpy2.rpc import client_context

tutorial_thrift = thriftpy2.load("tutorial.thrift",
module_name="tutorial_thrift")
module_name="tutorial_thrift")


def main():
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/tutorial_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from thriftpy2.rpc import make_server

tutorial_thrift = thriftpy2.load("tutorial.thrift",
module_name="tutorial_thrift")
module_name="tutorial_thrift")


class CalculatorHandler(object):
Expand Down
27 changes: 27 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,30 @@ license_files = LICENSE

[wheel]
universal = 1

[flake8]
filename = *.py, *.pyx
max-line-length = 80
exclude =
setup.py,
.git,
__pycache__,
docs,
build,
dist,
.tox,
venv*
ignore =
# Ambiguous variable names
E741
# Line break before bin op - https://www.flake8rules.com/rules/W503.html
W503
# Cython requires special flags since it is not proper Python
# E211: missing whitespace before '('
# E225: missing whitespace around operator
# E226: missing whitespace around arithmetic operator
# E227: missing whitespace around bitwise or shift operator
# E251: Unexpected spaces around keyword / parameter equals (types in function definitions)
# E402: module level import not at top of file
# E999: Internal AST compilation error (flake8 specific)
per-file-ignores = *.pyx: E211,E225,E226,E227,E251,E402,E999
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@
packages=find_packages(exclude=['benchmark', 'docs', 'tests']),
entry_points={},
url="https://thriftpy2.readthedocs.io/",
project_urls={
"Source": "https://github.com/Thriftpy/thriftpy2",
},
license="MIT",
zip_safe=False,
long_description=open("README.rst").read(),
install_requires=install_requires,
tests_require=tornado_requires,
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',
extras_require={
"dev": dev_requires,
"tornado": tornado_requires
Expand All @@ -107,6 +110,10 @@
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
])
19 changes: 19 additions & 0 deletions tests/container.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,22 @@ struct MixItem {
1: optional list<map<string, string>> list_map,
2: optional map<string, list<string>> map_list,
}

struct BinListStruct {
1: optional list<ListItem> list_items,
}

struct BinListItem {
1: optional list<binary> list_binary,
2: optional list<list<binary>> list_list_binary,
}

struct BinMapItem {
1: optional map<binary, binary> map_binary,
2: optional map<binary, map<binary, binary>> map_map_binary,
}

struct BinMixItem {
1: optional list<map<binary, binary>> list_map,
2: optional map<binary, list<binary>> map_list,
}
2 changes: 2 additions & 0 deletions tests/parser-cases/annotations.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

typedef list<i32> ( cpp.template = "std::list" ) int_linked_list

const string id = "id" (name="LANG_ID");

struct foo {
1: i32 bar ( presence = "required" );
2: i32 baz ( presence = "manual", cpp.use_pointer = "", );
Expand Down
Loading

0 comments on commit b74a8cd

Please sign in to comment.