Skip to content

Commit

Permalink
Merge branch 'master' into spdx-compliant-license
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin authored Sep 1, 2022
2 parents aeb6057 + ebaa593 commit 22387ba
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 125 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI

on: [push, pull_request]

jobs:
Windows:
name: 'Windows (${{ matrix.python }})'
runs-on: 'windows-latest'
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10']

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: test-requirements.txt
- name: Run tests
run: ./ci.sh
shell: bash
env:
# Should match 'name:' up above
JOB_NAME: 'Windows (${{ matrix.python }})'

Ubuntu:
name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
timeout-minutes: 10
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10', '3.11-dev']
check_formatting: ['0']
extra_name: ['']
include:
- python: '3.10'
check_formatting: '1'
extra_name: ', check formatting'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
if: "!endsWith(matrix.python, '-dev')"
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: test-requirements.txt
- name: Setup python (dev)
uses: deadsnakes/[email protected]
if: endsWith(matrix.python, '-dev')
with:
python-version: '${{ matrix.python }}'
- name: Run tests
run: ./ci.sh
env:
CHECK_FORMATTING: '${{ matrix.check_formatting }}'
# Should match 'name:' up above
JOB_NAME: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'

macOS:
name: 'macOS (${{ matrix.python }})'
timeout-minutes: 10
runs-on: 'macos-latest'
strategy:
fail-fast: false
matrix:
python: ['3.7', '3.8', '3.9', '3.10']
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: test-requirements.txt
- name: Run tests
run: ./ci.sh
env:
# Should match 'name:' up above
JOB_NAME: 'macOS (${{ matrix.python }})'
6 changes: 0 additions & 6 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ formats:

requirements_file: ci/rtd-requirements.txt

# Currently RTD's default image only has 3.5
# This gets us 3.6 (and hopefully 3.7 in the future)
# https://docs.readthedocs.io/en/latest/yaml-config.html#build-image
build:
image: latest

python:
version: 3
pip_install: True
57 changes: 57 additions & 0 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

set -ex

MYPY_VERSION=0.782
YAPF_VERSION=0.22.0


pip install -U pip setuptools wheel

if [ "$CHECK_FORMATTING" = "1" ]; then
pip install yapf==${YAPF_VERSION}
if ! yapf -rpd setup.py sniffio; then
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Formatting problems were found (listed above). To fix them, run
pip install yapf==${YAPF_VERSION}
yapf -rpi setup.py sniffio
in your local checkout.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOF
exit 1
fi
pip install mypy==${MYPY_VERSION}
if ! mypy --pretty sniffio; then
cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Type checking problems were found (listed above).
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EOF
exit 1
fi
exit 0
fi

python setup.py sdist --formats=zip
pip install dist/*.zip

# Actual tests
pip install -Ur test-requirements.txt

mkdir empty
cd empty

pytest -W error -ra -v --pyargs sniffio --cov=sniffio --cov-config=../.coveragerc --verbose

bash <(curl -s https://codecov.io/bash)
114 changes: 0 additions & 114 deletions ci/travis.sh

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"trio",
"asyncio",
],
python_requires=">=3.5",
python_requires=">=3.7",
tests_require=['curio'],
classifiers=[
"License :: OSI Approved :: MIT License",
Expand Down
11 changes: 7 additions & 4 deletions sniffio/_tests/test_sniffio.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys

import pytest
Expand Down Expand Up @@ -50,16 +51,18 @@ async def this_is_asyncio():
assert current_async_library() == "asyncio"
ran.append(True)

loop = asyncio.get_event_loop()
loop.run_until_complete(this_is_asyncio())
asyncio.run(this_is_asyncio())
assert ran == [True]
loop.close()

with pytest.raises(AsyncLibraryNotFoundError):
current_async_library()


@pytest.mark.skipif(sys.version_info < (3, 6), reason='Curio requires 3.6+')
# https://github.com/dabeaz/curio/pull/354
@pytest.mark.skipif(
os.name == "nt" and sys.version_info >= (3, 9),
reason="Curio breaks on Python 3.9+ on Windows. Fix was not released yet",
)
def test_curio():
import curio

Expand Down

0 comments on commit 22387ba

Please sign in to comment.