diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9d75fb5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,69 @@ +name: Test + +on: [push, pull_request] + +jobs: + build: + name: Python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} + strategy: + fail-fast: false + matrix: + python-version: + - '2.7' + - '3.5' + - '3.6' + - '3.7' + - '3.8' + - '3.9' + experimental: + - false + os: [ubuntu-latest] + include: + # Python 3.4 is not on ubuntu-latest + - python-version: '3.4' + os: ubuntu-18.04 + experimental: false + + # Python 3.10 is currently failing, but this may be OK + - python-version: '3.10.0-alpha - 3.10' + os: ubuntu-latest + experimental: true + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + id: install + run: | + set -x + pip install -r requirements.txt + + # install mypy on Python 3.6+ + if python -c \ + 'import sys; sys.exit(0 if sys.version_info >= (3, 6) else 1)'; then + pip install -U mypy + echo "::set-output name=mypy::true" + fi + + - name: Run pytest + run: | + pytest + + - name: Run mypy + if: ${{ steps.install.outputs.mypy }} + run: | + mypy pyannotate_* diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3456990..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: python -cache: pip -matrix: - include: - - python: '2.7' - - python: '3.4' - - python: '3.5.1' # Special, it doesn't have typing.Text - dist: trusty # needed because xenial doesn't have 3.5.1 - - python: '3.5' # Latest, e.g. 3.5.4 - - python: '3.6' - env: USE_MYPY=true - - python: '3.7' - dist: xenial # needed because Python 3.7 is broken on travis CI Trusty - sudo: true - env: USE_MYPY=true - - python: '3.8-dev' - dist: xenial # needed because Python 3.8 is broken on travis CI Trusty - sudo: true - env: USE_MYPY=true - allow_failures: - - python: 3.8-dev - -install: - - pip install -r requirements.txt - - if [[ $USE_MYPY == true ]]; then pip install -U mypy; fi -script: - - pytest - - if [[ $USE_MYPY == true ]]; then mypy pyannotate_*; fi diff --git a/pyannotate_tools/fixes/tests/test_annotate_json_py3.py b/pyannotate_tools/fixes/tests/test_annotate_json_py3.py index 09212be..9960d25 100644 --- a/pyannotate_tools/fixes/tests/test_annotate_json_py3.py +++ b/pyannotate_tools/fixes/tests/test_annotate_json_py3.py @@ -6,7 +6,11 @@ import tempfile import unittest import sys -from mock import patch + +try: + from unittest.mock import patch +except ImportError: + from mock import patch # type: ignore from lib2to3.tests.test_fixers import FixerTestCase diff --git a/requirements.txt b/requirements.txt index ffaffbd..da8a727 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,13 @@ +mock; python_version < '3.3' mypy_extensions>=0.3.0 -pytest>=3.3.0 +pytest>=3.3.0; python_version > '3.5' +# pytest >5.3.0 uses typing.Type from Python 3.5.2 +pytest>=3.3.0,<=5.3.0; python_version <= '3.5' +# importlib-metadata is needed for Python 3.5+, but pip does not seem to be +# pinning it to a correct version for Python 3.5 (possibly because it's a +# transitive dependency). +# Python 3.5 support was dropped in importlib-metadata 3.0.0 +importlib-metadata>=0.12,<3.0.0; python_version == '3.5' setuptools>=28.8.0 six>=1.11.0 typing>=3.6.2; python_version < '3.5'