Skip to content

Commit ea56f98

Browse files
committed
Add support to python 3.10 and 3.11
1 parent 95117b0 commit ea56f98

File tree

4 files changed

+66
-11
lines changed

4 files changed

+66
-11
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,60 @@ on:
1111
jobs:
1212
ci:
1313
runs-on: ${{ matrix.os }}
14-
container: docker://altendky/hydra:ubuntu-20.04-3-minors
1514
strategy:
1615
fail-fast: false
1716
matrix:
1817
os:
1918
- ubuntu-latest
19+
python:
20+
- version: "3.7"
21+
bin: python3.7
22+
tox: py37,report,codecov
23+
- version: "3.8"
24+
bin: python3.8
25+
tox: py38,report,codecov
26+
- version: "3.9"
27+
bin: python3.9
28+
tox: py39,report,codecov
29+
- version: "3.10"
30+
bin: python3.10
31+
tox: py310,report,codecov
32+
- version: "3.11"
33+
bin: python3.11
34+
tox: py311,report,codecov
35+
- version: pypy-3.7
36+
bin: pypy3
37+
tox: pypy3,report,codecov
38+
env:
39+
TOXTOOLPYTHON: "${{ matrix.python.bin }}"
40+
steps:
41+
- uses: actions/checkout@v3
42+
- name: Setup Python
43+
uses: actions/setup-python@v4
44+
with:
45+
python-version: ${{ matrix.python.version }}
46+
- name: Install
47+
run: |
48+
pip install tox
49+
- name: Test
50+
run: |
51+
tox -v -e "${{ matrix.python.tox }}"
52+
linting:
53+
name: Linting
54+
runs-on: ubuntu-latest
55+
strategy:
56+
matrix:
57+
python: ["3.10"]
2058
toxenv:
21-
- py37,report,codecov
22-
- py38,report,codecov
23-
- py39,report,codecov
24-
- pypy3,report,codecov
2559
- doc
2660
- check
2761
steps:
28-
- uses: actions/checkout@v1
62+
- uses: actions/checkout@v3
63+
- name: Set up Python ${{ matrix.python }}
64+
uses: actions/setup-python@v4
65+
with:
66+
python-version: ${{ matrix.python }}
67+
architecture: x64
2968
- name: Install
3069
run: |
3170
pip install tox
@@ -37,6 +76,7 @@ jobs:
3776
runs-on: ubuntu-latest
3877
needs:
3978
- ci
79+
- linting
4080
steps:
4181
- name: This
4282
shell: python

changelog.d/238.changes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support to python 3.10 and 3.11.

src/desert/_make.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,8 @@ def field_for_schema(
298298

299299
field = marshmallow_union.Union(subfields)
300300

301-
# t.NewType returns a function with a __supertype__ attribute
302-
newtype_supertype = getattr(typ, "__supertype__", None)
303-
if newtype_supertype and inspect.isfunction(typ):
301+
newtype_supertype = _get_newtype_supertype(typ)
302+
if newtype_supertype:
304303
metadata.setdefault("description", typ.__name__)
305304
field = field_for_schema(newtype_supertype, default=default)
306305

@@ -370,6 +369,19 @@ def _get_field_default(
370369
raise TypeError(field)
371370

372371

372+
def _get_newtype_supertype(typ: t.Any) -> t.Any:
373+
newtype_supertype = getattr(typ, "__supertype__", None)
374+
if newtype_supertype:
375+
if (
376+
# Python<3.10: t.NewType returns a function with a __supertype__ attribute
377+
inspect.isfunction(typ)
378+
# Python>=3.10: t.NewType is a type
379+
or (isinstance(t.NewType, type) and isinstance(typ, t.NewType))
380+
):
381+
return newtype_supertype
382+
return None
383+
384+
373385
@attr.frozen
374386
class _DesertSentinel:
375387
pass

tox.ini

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ envlist =
55
clean,
66
check,
77
doc,
8-
{py37,py38,py39,pypy3},
8+
{py37,py38,py39,py310,py311,pypy3},
99
report
1010

1111
[testenv]
@@ -14,7 +14,9 @@ basepython =
1414
py37: {env:TOXPYTHON:python3.7}
1515
py38: {env:TOXPYTHON:python3.8}
1616
py39: {env:TOXPYTHON:python3.9}
17-
{doc,spell,bootstrap,clean,check,report,codecov}: {env:TOXTOOLPYTHON:python3.8}
17+
py310: {env:TOXPYTHON:python3.10}
18+
py311: {env:TOXPYTHON:python3.11}
19+
{doc,spell,bootstrap,clean,check,report,codecov}: {env:TOXTOOLPYTHON:python3.10}
1820
setenv =
1921
PYTHONPATH={toxinidir}/tests
2022
PYTHONUNBUFFERED=yes

0 commit comments

Comments
 (0)