Skip to content

Commit

Permalink
conditionally require exceptiongroup (#183)
Browse files Browse the repository at this point in the history
also:  add python 3.12 and pypy3.9, 3.10 to CI
  • Loading branch information
jakkdl authored Sep 26, 2023
1 parent 326298b commit 929bf75
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ on:
- master
pull_request:

# pylint crashes on 3.12 due to https://github.com/pylint-dev/astroid/issues/2201
# see https://github.com/pylint-dev/pylint/issues/8782
jobs:
build_and_test_pinned:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -52,7 +54,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['pypy-3.7']
python-version: ['pypy-3.9','pypy-3.10']

steps:
- uses: actions/checkout@v3
Expand All @@ -70,7 +72,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.11']
python-version: ['3.12-dev']
steps:
- uses: actions/checkout@v3
- name: Setup Python
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ click==8.1.3
# via pip-tools
coverage[toml]==7.2.1
# via pytest-cov
cryptography==39.0.2
cryptography==41.0.4
# via trustme
exceptiongroup==1.1.0
# via
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
python_requires=">=3.7",
keywords='websocket client server trio',
packages=find_packages(exclude=['docs', 'examples', 'tests']),
install_requires=[
'exceptiongroup',
'exceptiongroup; python_version<"3.11"',
'trio>=0.11',
'wsproto>=0.14',
],
Expand Down
7 changes: 5 additions & 2 deletions trio_websocket/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import trio
import trio.abc
from exceptiongroup import BaseExceptionGroup
from wsproto import ConnectionType, WSConnection
from wsproto.connection import ConnectionState
import wsproto.frame_protocol as wsframeproto
Expand All @@ -30,6 +29,10 @@
)
import wsproto.utilities

if sys.version_info < (3, 11): # pragma: no cover
# pylint doesn't care about the version_info check, so need to ignore the warning
from exceptiongroup import BaseExceptionGroup # pylint: disable=redefined-builtin

_TRIO_MULTI_ERROR = tuple(map(int, trio.__version__.split('.')[:2])) < (0, 22)

CONN_TIMEOUT = 60 # default connect & disconnect timeout, in seconds
Expand Down Expand Up @@ -65,7 +68,7 @@ def __exit__(self, ty, value, tb):
if value is None or not self._armed:
return False

if _TRIO_MULTI_ERROR:
if _TRIO_MULTI_ERROR: # pragma: no cover
filtered_exception = trio.MultiError.filter(_ignore_cancel, value) # pylint: disable=no-member
elif isinstance(value, BaseExceptionGroup):
filtered_exception = value.subgroup(lambda exc: not isinstance(exc, trio.Cancelled))
Expand Down

0 comments on commit 929bf75

Please sign in to comment.