Skip to content

Commit ad82782

Browse files
authored
Merge pull request #88 from necaris/update-test-matrix
Add Python 3.11 to test matrix
2 parents 22bdedc + d17ab72 commit ad82782

File tree

8 files changed

+601
-579
lines changed

8 files changed

+601
-579
lines changed

.github/workflows/tests.yaml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,24 @@ jobs:
66
name: lint
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v3
10-
- uses: actions/setup-python@v3
11-
with:
12-
python-version: 3.8
13-
- uses: pre-commit/[email protected]
14-
pytest:
9+
- uses: actions/checkout@v3
10+
- uses: actions/setup-python@v4
11+
with:
12+
python-version: "3.10"
13+
- uses: pre-commit/[email protected]
14+
tests:
1515
name: pytest
1616
runs-on: ubuntu-latest
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
python-version: ["3.7", "3.8", "3.9", "3.10"]
20+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
2121
os: [ubuntu-latest, macos-latest, windows-latest]
2222
steps:
23-
- uses: actions/checkout@master
24-
- uses: actions/setup-python@v2
23+
- uses: actions/checkout@v3
24+
- uses: actions/setup-python@v4
2525
with:
2626
python-version: ${{ matrix.python-version }}
27-
- name: Ensure poetry
28-
uses: abatilo/[email protected]
29-
- name: Install dependencies
30-
run: poetry install
31-
- name: Run matrix of tests with Tox
32-
run: poetry run tox
27+
- uses: abatilo/actions-poetry@v2
28+
- run: poetry install
29+
- run: poetry run nox --non-interactive

.pre-commit-config.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
default_language_version:
2-
python: python3.8
31
fail_fast: true
42
repos:
5-
- repo: git://github.com/pre-commit/pre-commit-hooks
6-
rev: v2.1.0
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v3.0.0
75
hooks:
8-
- id: check-merge-conflict
9-
- id: check-yaml
10-
- id: debug-statements
11-
- id: end-of-file-fixer
12-
exclude: ^docs/.*$
13-
- id: trailing-whitespace
14-
exclude: README.md
15-
- id: flake8
6+
- id: check-merge-conflict
7+
- id: check-yaml
8+
- id: debug-statements
9+
- id: end-of-file-fixer
10+
exclude: ^docs/.*$
11+
- id: trailing-whitespace
12+
exclude: README.md
13+
- repo: https://github.com/pycqa/flake8
14+
rev: "6.1.0"
15+
hooks:
16+
- id: flake8
1617
- repo: https://github.com/pre-commit/mirrors-mypy
17-
rev: v0.812
18+
rev: v1.4.1
1819
hooks:
1920
- id: mypy
2021
args: [--ignore-missing-imports, --no-strict-optional]
21-
- repo: https://github.com/python/black
22-
rev: 20.8b1
22+
- repo: https://github.com/psf/black
23+
rev: 23.7.0
2324
hooks:
2425
- id: black

graphene_pydantic/converters.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,16 @@ def convert_pydantic_field(
137137
field_type = field_kwargs.pop("type", field_kwargs.pop("type_", None))
138138
if field_type is None:
139139
raise ValueError("No field type could be determined.")
140-
141-
resolver_function = getattr(parent_type,
142-
"resolve_" + field.name,
143-
None)
140+
141+
resolver_function = getattr(parent_type, "resolve_" + field.name, None)
144142
if resolver_function and callable(resolver_function):
145143
field_resolver = resolver_function
146144
else:
147145
field_resolver = get_attr_resolver(field.name)
148146

149147
return Field(field_type, resolver=field_resolver, **field_kwargs)
150148

149+
151150
def convert_pydantic_type(
152151
type_: T.Type,
153152
field: ModelField,
@@ -293,19 +292,15 @@ def convert_generic_python_type(
293292
return convert_literal_type(
294293
type_, field, registry, parent_type=parent_type, model=model
295294
)
296-
elif (
297-
origin
298-
in (
299-
T.Tuple,
300-
T.List,
301-
T.Set,
302-
T.Collection,
303-
T.Iterable,
304-
list,
305-
set,
306-
)
307-
or issubclass(origin, collections.abc.Sequence)
308-
):
295+
elif origin in (
296+
T.Tuple,
297+
T.List,
298+
T.Set,
299+
T.Collection,
300+
T.Iterable,
301+
list,
302+
set,
303+
) or issubclass(origin, collections.abc.Sequence):
309304
# TODO: find a better way of divining that the origin is sequence-like
310305
inner_types = getattr(type_, "__args__", [])
311306
if not inner_types: # pragma: no cover # this really should be impossible

noxfile.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import sys
2+
from nox import parametrize, session
3+
4+
5+
@session
6+
@parametrize(
7+
"pydantic",
8+
("1.9", "1.10", "1.7", "1.8"),
9+
)
10+
def tests(session, pydantic):
11+
if sys.version_info > (3, 10) and pydantic in ("1.7", "1.8"):
12+
return session.skip()
13+
session.install(f"pydantic=={pydantic}")
14+
session.install("pytest", "pytest-cov", ".")
15+
session.run(
16+
"pytest", "-v", "tests/", "--cov-report=term-missing", "--cov=graphene_pydantic"
17+
)

poetry.lock

Lines changed: 531 additions & 497 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ description = "Graphene Pydantic integration"
55
readme = "README.md"
66
repository = "https://github.com/graphql-python/graphene-pydantic"
77
authors = [
8-
"Rami Chowdhury <[email protected]>"
8+
"Rami Chowdhury <[email protected]>",
9+
"Dan Riggs <[email protected]>",
910
]
1011
license = "Apache-2.0"
1112
classifiers = [
@@ -23,21 +24,20 @@ keywords = ["api", "graphql", "protocol", "rest", "relay", "graphene", "pydantic
2324

2425
[tool.poetry.dependencies]
2526
python = "^3.7"
26-
# To keep things simple, we only support newer versions of Graphene & Pydantic
27-
graphene = ">=2.1.8"
27+
graphene = ">=3.0"
2828
pydantic = [
29-
{ version = ">=1.0,<2.0", python = ">3.6,<3.10" },
29+
{ version = ">=1.0,<2.0", python = ">3.6,<3.12" },
3030
{ version = ">=1.9,<2.0", python = ">=3.10" }
3131
]
3232

33-
[tool.poetry.dev-dependencies]
33+
[tool.poetry.group.dev.dependencies]
3434
pytest = "~6.2"
3535
pytest-cov = "~2.7.1"
36-
tox = "~3.12.0" # sync with tox.ini
37-
mypy = "0.901"
38-
black = "21.12b0"
39-
pre-commit = "~1.17.0"
36+
mypy = "^1.4.1"
37+
black = "23.3"
38+
pre-commit = "^2.9.2"
39+
nox = "^2023.4.22"
4040

4141
[build-system]
42-
requires = ["poetry>=1.0"]
42+
requires = ["poetry>=1.5"]
4343
build-backend = "poetry.masonry.api"

tests/test_converters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ def test_union():
7676
assert field.type.of_type.__name__.startswith("UnionOf")
7777

7878

79-
if sys.version_info >= (3, 8):
80-
# Python < 3.8 does not support typing.Literal
79+
if sys.version_info >= (3, 10):
80+
# Python < 3.10 does not support typing.Literal except as a
81+
# _SpecialGenericAlias, which Pydantic doesn't like
8182

8283
def test_literal():
8384
field = _convert_field_from_spec(

tox.ini

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)