Skip to content

Commit

Permalink
Support Python 3.13 and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Oct 19, 2024
1 parent 4e83d42 commit 2a7976f
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 214 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy3.9', 'pypy3.10']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy3.9', 'pypy3.10']

steps:
- uses: actions/checkout@v4
Expand Down
463 changes: 261 additions & 202 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13"
]
packages = [
{ include = "graphql", from = "src" },
Expand Down Expand Up @@ -75,9 +76,9 @@ tox = [
optional = true

[tool.poetry.group.lint.dependencies]
ruff = ">=0.6.4,<0.7"
ruff = ">=0.7,<0.8"
mypy = [
{ version = "^1.11", python = ">=3.8" },
{ version = "^1.12", python = ">=3.8" },
{ version = "~1.4", python = "<3.8" }
]
bump2version = ">=1.0,<2"
Expand Down
5 changes: 3 additions & 2 deletions src/graphql/language/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,9 @@ def parse_nullability_assertion(self) -> NullabilityAssertionNode | None:
def parse_arguments(self, is_const: bool) -> list[ArgumentNode]:
"""Arguments[Const]: (Argument[?Const]+)"""
item = self.parse_const_argument if is_const else self.parse_argument
item = cast(Callable[[], ArgumentNode], item)
return self.optional_many(TokenKind.PAREN_L, item, TokenKind.PAREN_R)
return self.optional_many(
TokenKind.PAREN_L, cast(Callable[[], ArgumentNode], item), TokenKind.PAREN_R
)

def parse_argument(self, is_const: bool = False) -> ArgumentNode:
"""Argument[Const]: Name : Value[?Const]"""
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/language/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def visit(
else:
stack = Stack(in_array, idx, keys, edits, stack)
in_array = isinstance(node, tuple)
keys = node if in_array else visitor_keys.get(node.kind, ())
keys = node if in_array else visitor_keys.get(node.kind, ()) # type: ignore
idx = -1
edits = []
if parent:
Expand Down
6 changes: 4 additions & 2 deletions src/graphql/pyutils/async_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def async_reduce(
async def async_callback(
current_accumulator: Awaitable[U], current_value: T
) -> U:
result = callback(await current_accumulator, current_value)
return await cast(Awaitable, result) if is_awaitable(result) else result
result: AwaitableOrValue[U] = callback(
await current_accumulator, current_value
)
return await result if is_awaitable(result) else result # type: ignore

accumulator = async_callback(cast(Awaitable[U], accumulator), value)
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/execution/test_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def execute_query(
assert isinstance(schema, GraphQLSchema)
assert isinstance(query, str)
document = parse(query)
result = (execute_sync if sync else execute)(schema, document, root_value) # type: ignore
result = (execute_sync if sync else execute)(schema, document, root_value)
if not sync and is_awaitable(result):
result = await result
assert isinstance(result, ExecutionResult)
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ python =

[testenv:ruff]
basepython = python3.12
deps = ruff>=0.6.4,<0.7
deps = ruff>=0.7,<0.8
commands =
ruff check src tests
ruff format --check src tests

[testenv:mypy]
basepython = python3.12
deps =
mypy>=1.11,<2
mypy>=1.12,<2
pytest>=8.3,<9
commands =
mypy src tests
Expand All @@ -50,5 +50,5 @@ deps =
commands =
# to also run the time-consuming tests: tox -e py311 -- --run-slow
# to run the benchmarks: tox -e py311 -- -k benchmarks --benchmark-enable
py3{7,8,9,10,11}, pypy3{9,10}: pytest tests {posargs}
py3{7,8,9,10,11,13}, pypy3{9,10}: pytest tests {posargs}
py312: pytest tests {posargs: --cov-report=term-missing --cov=graphql --cov=tests --cov-fail-under=100}

0 comments on commit 2a7976f

Please sign in to comment.