Skip to content

Commit

Permalink
Merge branch 'main' into memory_channel_named_tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolCat467 committed Aug 1, 2024
2 parents 4f78539 + 20f9291 commit 5a40d70
Show file tree
Hide file tree
Showing 204 changed files with 7,516 additions and 4,873 deletions.
37 changes: 0 additions & 37 deletions .coveragerc

This file was deleted.

14 changes: 8 additions & 6 deletions .github/workflows/autodeps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

jobs:
Autodeps:
if: github.repository_owner == 'python-trio'
name: Autodeps
timeout-minutes: 10
runs-on: 'ubuntu-latest'
Expand All @@ -18,23 +19,24 @@ jobs:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Bump dependencies
run: |
python -m pip install -U pip
python -m pip install -U pip pre-commit
python -m pip install -r test-requirements.txt
pip-compile -U test-requirements.in
pip-compile -U docs-requirements.in
uv pip compile --universal --python-version=3.8 --upgrade test-requirements.in -o test-requirements.txt
uv pip compile --universal --python-version=3.8 --upgrade docs-requirements.in -o docs-requirements.txt
pre-commit autoupdate --jobs 0
- name: Black
run: |
# The new dependencies may contain a new black version.
# Commit any changes immediately.
python -m pip install -r test-requirements.txt
black setup.py trio
black src/trio
- name: Commit changes and create automerge PR
env:
GH_TOKEN: ${{ github.token }}
Expand Down
86 changes: 70 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,11 @@ jobs:
strategy:
fail-fast: false
matrix:
# pypy 3.9 and 3.10 are failing, see https://github.com/python-trio/trio/issues/2678 and https://github.com/python-trio/trio/issues/2776 respectively
python: ['3.8', '3.9', '3.10'] #, 'pypy-3.9-nightly', 'pypy-3.10-nightly']
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
arch: ['x86', 'x64']
lsp: ['']
lsp_extract_file: ['']
extra_name: ['']
exclude:
# pypy does not release 32-bit binaries
- python: 'pypy-3.9-nightly'
arch: 'x86'
#- python: 'pypy-3.10-nightly'
# arch: 'x86'
include:
- python: '3.8'
arch: 'x64'
Expand Down Expand Up @@ -57,9 +50,9 @@ jobs:
}}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
# This allows the matrix to specify just the major.minor version while still
# expanding it to get the latest patch version including alpha releases.
Expand Down Expand Up @@ -94,7 +87,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['pypy-3.9', 'pypy-3.10', '3.8', '3.9', '3.10', '3.11', '3.12-dev', 'pypy-3.9-nightly', 'pypy-3.10-nightly']
python: ['pypy-3.9', 'pypy-3.10', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
check_formatting: ['0']
no_test_requirements: ['0']
extra_name: ['']
Expand All @@ -117,9 +110,9 @@ jobs:
}}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
if: "!endsWith(matrix.python, '-dev')"
with:
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
Expand Down Expand Up @@ -150,7 +143,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.8', '3.9', '3.10', 'pypy-3.9-nightly', 'pypy-3.10-nightly']
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
continue-on-error: >-
${{
(
Expand All @@ -162,9 +155,9 @@ jobs:
}}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }}
cache: pip
Expand All @@ -179,6 +172,65 @@ jobs:
name: macOS (${{ matrix.python }})
flags: macOS,${{ matrix.python }}

# run CI on a musl linux
Alpine:
name: "Alpine"
runs-on: ubuntu-latest
container: alpine
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install necessary packages
# can't use setup-python because that python doesn't seem to work;
# `python3-dev` (rather than `python:alpine`) for some ctypes reason,
# `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test).
run: apk update && apk add python3-dev bash nodejs
- name: Enter virtual environment
run: python -m venv .venv
- name: Run tests
run: source .venv/bin/activate && ./ci.sh
- if: always()
uses: codecov/codecov-action@v3
with:
directory: empty
token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46
name: Alpine
flags: Alpine,3.12

Cython:
name: "Cython"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ['3.8', '3.12']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '${{ matrix.python }}'
cache: pip
# setuptools is needed to get distutils on 3.12, which cythonize requires
- name: install trio and setuptools
run: python -m pip install --upgrade pip . setuptools

- name: install cython<3
run: python -m pip install "cython<3"
- name: compile pyx file
run: cythonize -i tests/cython/test_cython.pyx
- name: import & run module
run: python -c 'import tests.cython.test_cython'

- name: install cython>=3
run: python -m pip install "cython>=3"
- name: compile pyx file
# different cython version should trigger a re-compile, but --force just in case
run: cythonize --inplace --force tests/cython/test_cython.pyx
- name: import & run module
run: python -c 'import tests.cython.test_cython'

# https://github.com/marketplace/actions/alls-green#why
check: # This job does nothing and is only used for the branch protection

Expand All @@ -188,6 +240,8 @@ jobs:
- Windows
- Ubuntu
- macOS
- Alpine
- Cython

runs-on: ubuntu-latest

Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -18,18 +18,18 @@ repos:
- id: check-case-conflict
- id: sort-simple-yaml
files: .pre-commit-config.yaml
- repo: https://github.com/psf/black
rev: 23.10.1
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.1
rev: v0.5.5
hooks:
- id: ruff
types: [file]
types_or: [python, pyi, toml]
args: ["--show-fixes"]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include LICENSE LICENSE.MIT LICENSE.APACHE2
include README.rst
include CODE_OF_CONDUCT.md CONTRIBUTING.md
include test-requirements.txt
include trio/py.typed
recursive-include trio/_tests/test_ssl_certs *.pem
include src/trio/py.typed
recursive-include src/trio/_tests/test_ssl_certs *.pem
recursive-include docs *
prune docs/build
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
:target: https://anaconda.org/conda-forge/trio
:alt: Latest conda-forge version

.. image:: https://codecov.io/gh/python-trio/trio/branch/master/graph/badge.svg
.. image:: https://codecov.io/gh/python-trio/trio/branch/main/graph/badge.svg
:target: https://codecov.io/gh/python-trio/trio
:alt: Test coverage

Expand All @@ -31,7 +31,7 @@ Trio – a friendly Python library for async concurrency and I/O

The Trio project aims to produce a production-quality,
`permissively licensed
<https://github.com/python-trio/trio/blob/master/LICENSE>`__,
<https://github.com/python-trio/trio/blob/main/LICENSE>`__,
async/await-native I/O library for Python. Like all async libraries,
its main purpose is to help you write programs that do **multiple
things at the same time** with **parallelized I/O**. A web spider that
Expand Down Expand Up @@ -134,7 +134,7 @@ choices
**I want to make sure my company's lawyers won't get angry at me!** No
worries, Trio is permissively licensed under your choice of MIT or
Apache 2. See `LICENSE
<https://github.com/python-trio/trio/blob/master/LICENSE>`__ for details.
<https://github.com/python-trio/trio/blob/main/LICENSE>`__ for details.


Code of conduct
Expand Down
33 changes: 14 additions & 19 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fi

# Test if the generated code is still up to date
echo "::group::Generate Exports"
python ./trio/_tools/gen_exports.py --test \
python ./src/trio/_tools/gen_exports.py --test \
|| EXIT_STATUS=$?
echo "::endgroup::"

Expand All @@ -23,10 +23,10 @@ echo "::endgroup::"
# autoflake --recursive --in-place .
# pyupgrade --py3-plus $(find . -name "*.py")
echo "::group::Black"
if ! black --check setup.py trio; then
if ! black --check src/trio; then
echo "* Black found issues" >> "$GITHUB_STEP_SUMMARY"
EXIT_STATUS=1
black --diff setup.py trio
black --diff src/trio
echo "::endgroup::"
echo "::error:: Black found issues"
else
Expand Down Expand Up @@ -57,16 +57,16 @@ echo "::group::Mypy"
rm -f mypy_annotate.dat
# Pipefail makes these pipelines fail if mypy does, even if mypy_annotate.py succeeds.
set -o pipefail
mypy trio --show-error-end --platform linux | python ./trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
mypy --show-error-end --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
|| { echo "* Mypy (Linux) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
# Darwin tests FreeBSD too
mypy trio --show-error-end --platform darwin | python ./trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
mypy --show-error-end --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
|| { echo "* Mypy (Mac) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
mypy trio --show-error-end --platform win32 | python ./trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
mypy --show-error-end --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
|| { echo "* Mypy (Windows) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
set +o pipefail
# Re-display errors using Github's syntax, read out of mypy_annotate.dat
python ./trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat
python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat
# Then discard.
rm -f mypy_annotate.dat
echo "::endgroup::"
Expand All @@ -78,10 +78,10 @@ fi

# Check pip compile is consistent
echo "::group::Pip Compile - Tests"
pip-compile test-requirements.in
uv pip compile --universal --python-version=3.8 test-requirements.in -o test-requirements.txt
echo "::endgroup::"
echo "::group::Pip Compile - Docs"
pip-compile docs-requirements.in
uv pip compile --universal --python-version=3.8 docs-requirements.in -o docs-requirements.txt
echo "::endgroup::"

if git status --porcelain | grep -q "requirements.txt"; then
Expand All @@ -97,15 +97,10 @@ fi
codespell || EXIT_STATUS=$?

echo "::group::Pyright interface tests"
python trio/_tests/check_type_completeness.py --overwrite-file || EXIT_STATUS=$?
if git status --porcelain trio/_tests/verify_types*.json | grep -q "M"; then
echo "* Type completeness changed, please update!" >> "$GITHUB_STEP_SUMMARY"
echo "::error::Type completeness changed, please update!"
git --no-pager diff --color trio/_tests/verify_types*.json
EXIT_STATUS=1
fi
python src/trio/_tests/check_type_completeness.py || EXIT_STATUS=$?

pyright trio/_tests/type_tests || EXIT_STATUS=$?
pyright src/trio/_tests/type_tests || EXIT_STATUS=$?
pyright src/trio/_core/_tests/type_tests || EXIT_STATUS=$?
echo "::endgroup::"

# Finally, leave a really clear warning of any issues and exit
Expand All @@ -118,8 +113,8 @@ Problems were found by static analysis (listed above).
To fix formatting and see remaining errors, run
pip install -r test-requirements.txt
black setup.py trio
isort setup.py trio
black src/trio
ruff check src/trio
./check.sh
in your local checkout.
Expand Down
Loading

0 comments on commit 5a40d70

Please sign in to comment.