Skip to content
This repository was archived by the owner on Mar 8, 2023. It is now read-only.

Re-support Python 2 #173

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ jobs:
strategy:
matrix:
python-version:
- '2.7'
- '3.7'
- '3.8'
- '3.9'
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
cython>=0.29.29
six
ply
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -150,7 +150,7 @@ def run(self):
url='https://github.com/thriftrw/thriftrw-python',
packages=find_packages(exclude=('tests', 'tests.*')),
license='MIT',
install_requires=['ply'],
install_requires=['six', 'ply'],
tests_require=['pytest', 'mock'],
classifiers=[
'Development Status :: 5 - Production/Stable',
2 changes: 2 additions & 0 deletions tests/spec/test_hashable.py
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
from __future__ import absolute_import, unicode_literals, print_function

import pytest
import six


@pytest.mark.parametrize('name, src, kwargs', [
@@ -98,6 +99,7 @@ def test_hash_inequality(loads, name, src, kwargs1, kwargs2):
assert hash(obj1) != hash(obj2)


@pytest.mark.skipif(six.PY2, reason="All Python 2 classes are hashable")
@pytest.mark.parametrize('name, src, kwargs', [
(
'Foo', '''
3 changes: 2 additions & 1 deletion tests/spec/test_struct.py
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
from __future__ import absolute_import, unicode_literals, print_function

import pytest
import six

from thriftrw.errors import ThriftCompilerError
from thriftrw.spec.struct import StructTypeSpec
@@ -321,7 +322,7 @@ def test_default_binary_value(loads):
1: optional binary field = "";
}''').Struct

assert isinstance(Struct().field, bytes)
assert isinstance(Struct().field, six.binary_type)


def test_constructor_behavior(loads):
3 changes: 2 additions & 1 deletion thriftrw/idl/lexer.py
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@

from __future__ import absolute_import, unicode_literals, print_function

import six
from ply import lex

from ..errors import ThriftParserError
@@ -73,7 +74,7 @@ class LexerSpec(object):
'DUBCONSTANT',
'LITERAL',
'IDENTIFIER',
) + tuple(map(str.upper, THRIFT_KEYWORDS))
) + tuple(map(six.text_type.upper, THRIFT_KEYWORDS))

t_ignore = ' \t\r' # whitespace

15 changes: 13 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
[tox]
envlist = 3.7,3.8,3.9,3.10,3.11,cover,flake8,docs
envlist = 2.7,3.7,3.8,3.9,3.10,3.11,cover,flake8,docs
usedevelop = true

[testenv]
commands =
python setup.py clean --all build_ext --force --inplace
py.test -svv tests
basepython =
2.7: python2.7
3.7: python3.7
3.8: python3.8
3.9: python3.9
3.10: python3.10
3.11: python3.11
deps = -rrequirements-test.txt
deps =
2.7: py-cpuinfo==8.0.0
2.7: pytest==4.6.11
2.7: pytest-cov==2.12.1
2.7: pytest-benchmark==3.4.1
3.7: -rrequirements-test.txt
3.8: -rrequirements-test.txt
3.9: -rrequirements-test.txt
3.10: -rrequirements-test.txt
3.11: -rrequirements-test.txt

[testenv:cover]
basepython = python
@@ -37,5 +47,6 @@ basepython = python
changedir = docs
deps =
sphinx
six
ply
commands = make html