Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 1 addition & 42 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

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

steps:
- name: Checkout project
Expand Down Expand Up @@ -37,44 +37,3 @@ jobs:
- name: Run unit tests with tox
id: test
run: tox

tests-old:
name: 🧪 Tests (older Python versions)
runs-on: ubuntu-22.04

strategy:
matrix:
python-version: ['3.7', '3.8']

steps:
- name: Checkout project
id: checkout
uses: actions/checkout@v5

- name: Set up Python 3.14 (tox runner)
id: setup-python
uses: actions/setup-python@v6
with:
python-version: '3.14'

- name: Install uv
id: setup-uv
uses: astral-sh/setup-uv@v6

- name: Install tox and plugins
id: install-tox
run: |
uv pip install --system tox tox-uv tox-gh-actions

- name: Set up target Python ${{ matrix.python-version }}
id: setup-target-python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Run unit tests with tox for target
id: test
shell: bash
run: |
ENV="py${{ matrix.python-version }}"; ENV=${ENV/./}
python3.14 -m tox -e "$ENV"
18 changes: 9 additions & 9 deletions docs/usage/parser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ This will give the same result as manually creating the AST document::

from graphql.language.ast import *

document = DocumentNode(definitions=[
document = DocumentNode(definitions=(
ObjectTypeDefinitionNode(
name=NameNode(value='Query'),
fields=[
fields=(
FieldDefinitionNode(
name=NameNode(value='me'),
type=NamedTypeNode(name=NameNode(value='User')),
arguments=[], directives=[])
], directives=[], interfaces=[]),
arguments=(), directives=()),
), interfaces=(), directives=()),
ObjectTypeDefinitionNode(
name=NameNode(value='User'),
fields=[
fields=(
FieldDefinitionNode(
name=NameNode(value='id'),
type=NamedTypeNode(
name=NameNode(value='ID')),
arguments=[], directives=[]),
arguments=(), directives=()),
FieldDefinitionNode(
name=NameNode(value='name'),
type=NamedTypeNode(
name=NameNode(value='String')),
arguments=[], directives=[]),
], directives=[], interfaces=[]),
])
arguments=(), directives=()),
), interfaces=(), directives=()),
))


When parsing with ``no_location=False`` (the default), the AST nodes will also have a
Expand Down
42 changes: 12 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "graphql-core"
version = "3.3.0a11"
description = "GraphQL-core is a Python port of GraphQL.js, the JavaScript reference implementation for GraphQL."
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.10"
license = "MIT"
license-files = ["LICENSE"]
authors = [ { name = "Christoph Zwerschke", email = "[email protected]" } ]
Expand All @@ -13,18 +13,14 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dependencies = [
"typing-extensions>=4.12.2,<5; python_version >= '3.8' and python_version < '3.10'",
"typing-extensions>=4.7.1,<5; python_version < '3.8'",
"msgspec>=0.19",
]

[project.urls]
Expand All @@ -35,36 +31,22 @@ Changelog = "https://github.com/graphql-python/graphql-core/releases"

[dependency-groups]
test = [
"anyio>=4.6; python_version>='3.9'",
"anyio>=3.7; python_version<'3.9'",
"pytest>=8.4; python_version>='3.9'",
"pytest>=8.3; python_version>='3.8' and python_version<'3.9'",
"pytest>=7.4,<8; python_version<'3.8'",
"pytest-benchmark>=5.2; python_version>='3.9'",
"pytest-benchmark>=4.0,<5; python_version<'3.9'",
"pytest-cov>=6.0; python_version>='3.9'",
"pytest-cov>=5.0,<6; python_version>='3.8' and python_version<'3.9'",
"pytest-cov>=4.1,<5; python_version<'3.8'",
"pytest-describe>=3.0; python_version>='3.9'",
"pytest-describe>=2.2; python_version<'3.9'",
"anyio>=4.6",
"pytest>=8.4",
"pytest-benchmark>=5.2",
"pytest-cov>=6.0",
"pytest-describe>=3.0",
"pytest-timeout>=2.4",
"pytest-codspeed>=3.1; python_version>='3.9'",
"pytest-codspeed>=2.2,<3; python_version<'3.8'",
"tox>=4.32; python_version>='3.10'",
"tox>=4.24; python_version>='3.8' and python_version<'3.10'",
"tox>=3.28,<4; python_version<'3.8'",
"pytest-codspeed>=3.1",
"tox>=4.32",
]
lint = [
"ruff>=0.14,<0.15",
"mypy>=1.18; python_version>='3.9'",
"mypy>=1.14; python_version>='3.8' and python_version<'3.9'",
"mypy>=1.4; python_version<'3.8'",
"mypy>=1.18",
"bump2version>=1,<2",
]
doc = [
"sphinx>=8,<10; python_version>='3.10'",
"sphinx>=7,<9; python_version>='3.8' and python_version<'3.10'",
"sphinx>=4,<6; python_version<'3.8'",
"sphinx>=8,<10",
"sphinx_rtd_theme>=2,<4",
]

Expand Down Expand Up @@ -93,7 +75,7 @@ source-exclude = [

[tool.ruff]
line-length = 88
target-version = "py37"
target-version = "py310"

[tool.ruff.lint]
select = [
Expand Down
8 changes: 5 additions & 3 deletions src/graphql/error/graphql_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from sys import exc_info
from typing import TYPE_CHECKING, Any, Collection, Dict
from typing import TYPE_CHECKING, Any

try:
from typing import TypedDict
Expand All @@ -12,9 +12,11 @@
try:
from typing import TypeAlias
except ImportError: # Python < 3.10
from typing_extensions import TypeAlias
from typing import TypeAlias

if TYPE_CHECKING:
from collections.abc import Collection

from ..language.ast import Node
from ..language.location import (
FormattedSourceLocation,
Expand All @@ -26,7 +28,7 @@


# Custom extensions
GraphQLErrorExtensions: TypeAlias = Dict[str, Any]
GraphQLErrorExtensions: TypeAlias = dict[str, Any]
# Use a unique identifier name for your extension, for example the name of
# your library or project. Do not use a shortened identifier as this increases
# the risk of conflicts. We recommend you add at most one extension key,
Expand Down
4 changes: 3 additions & 1 deletion src/graphql/error/located_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
from __future__ import annotations

from contextlib import suppress
from typing import TYPE_CHECKING, Collection
from typing import TYPE_CHECKING

from ..language.source import Source, is_source
from ..pyutils import inspect
from .graphql_error import GraphQLError

if TYPE_CHECKING:
from collections.abc import Collection

from ..language.ast import Node

__all__ = ["located_error"]
Expand Down
8 changes: 2 additions & 6 deletions src/graphql/execution/async_iterables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@

from __future__ import annotations

from collections.abc import AsyncGenerator, AsyncIterable, Awaitable, Callable
from contextlib import AbstractAsyncContextManager, suppress
from typing import (
AsyncGenerator,
AsyncIterable,
Awaitable,
Callable,
Generic,
TypeVar,
Union,
)

__all__ = ["aclosing", "map_async_iterable"]

T = TypeVar("T")
V = TypeVar("V")

AsyncIterableOrGenerator = Union[AsyncGenerator[T, None], AsyncIterable[T]]
AsyncIterableOrGenerator = AsyncGenerator[T, None] | AsyncIterable[T]

suppress_exceptions = suppress(Exception)

Expand Down
2 changes: 1 addition & 1 deletion src/graphql/execution/build_field_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
try:
from typing import TypeAlias
except ImportError: # Python < 3.10
from typing_extensions import TypeAlias
from typing import TypeAlias

__all__ = [
"DeferUsageSet",
Expand Down
13 changes: 3 additions & 10 deletions src/graphql/execution/collect_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

import sys
from collections import defaultdict
from typing import Any, NamedTuple

Expand All @@ -29,7 +28,7 @@
try:
from typing import TypeAlias
except ImportError: # Python < 3.10
from typing_extensions import TypeAlias
from typing import TypeAlias

__all__ = [
"CollectFieldsContext",
Expand Down Expand Up @@ -67,14 +66,8 @@ class FieldDetails(NamedTuple):
defer_usage: DeferUsage | None


if sys.version_info < (3, 9):
from typing import Dict, List

FieldGroup: TypeAlias = List[FieldDetails]
GroupedFieldSet: TypeAlias = Dict[str, FieldGroup]
else: # Python >= 3.9
FieldGroup: TypeAlias = list[FieldDetails]
GroupedFieldSet: TypeAlias = dict[str, FieldGroup]
FieldGroup: TypeAlias = list[FieldDetails]
GroupedFieldSet: TypeAlias = dict[str, FieldGroup]


class CollectFieldsContext(NamedTuple):
Expand Down
Loading