Skip to content

Commit

Permalink
Update dependencies and fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Jul 21, 2024
1 parent 876aef6 commit 730ac15
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 145 deletions.
230 changes: 115 additions & 115 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ optional = true

[tool.poetry.group.test.dependencies]
pytest = [
{ version = "^8.2", python = ">=3.8" },
{ version = "^8.3", python = ">=3.8" },
{ version = "^7.4", python = "<3.8"}
]
pytest-asyncio = [
{ version = "^0.23.6", python = ">=3.8" },
{ version = "^0.23.8", python = ">=3.8" },
{ version = "~0.21.1", python = "<3.8"}
]
pytest-benchmark = "^4.0"
Expand All @@ -67,15 +67,15 @@ pytest-cov = [
pytest-describe = "^2.2"
pytest-timeout = "^2.3"
tox = [
{ version = "^4.14", python = ">=3.8" },
{ version = "^4.16", python = ">=3.8" },
{ version = "^3.28", python = "<3.8" }
]

[tool.poetry.group.lint]
optional = true

[tool.poetry.group.lint.dependencies]
ruff = ">=0.5.1,<0.6"
ruff = ">=0.5.3,<0.6"
mypy = [
{ version = "^1.10", python = ">=3.8" },
{ version = "~1.4", python = "<3.8" }
Expand Down
5 changes: 3 additions & 2 deletions src/graphql/execution/async_iterables.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
AsyncIterable,
Awaitable,
Callable,
Generic,
TypeVar,
Union,
)
Expand All @@ -20,7 +21,7 @@
AsyncIterableOrGenerator = Union[AsyncGenerator[T, None], AsyncIterable[T]]


class aclosing(AbstractAsyncContextManager): # noqa: N801
class aclosing(AbstractAsyncContextManager, Generic[T]): # noqa: N801
"""Async context manager for safely finalizing an async iterator or generator.
Contrary to the function available via the standard library, this one silently
Expand Down Expand Up @@ -52,6 +53,6 @@ async def map_async_iterable(
If the inner iterator supports an `aclose()` method, it will be called when
the generator finishes or closes.
"""
async with aclosing(iterable) as items: # type: ignore
async with aclosing(iterable) as items:
async for item in items:
yield await callback(item)
16 changes: 10 additions & 6 deletions src/graphql/utilities/extend_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,24 @@
GraphQLInputField,
GraphQLInputFieldMap,
GraphQLInputObjectType,
GraphQLInputObjectTypeKwargs,
GraphQLInputType,
GraphQLInterfaceType,
GraphQLInterfaceTypeKwargs,
GraphQLList,
GraphQLNamedType,
GraphQLNonNull,
GraphQLNullableType,
GraphQLObjectType,
GraphQLObjectTypeKwargs,
GraphQLOutputType,
GraphQLScalarType,
GraphQLSchema,
GraphQLSchemaKwargs,
GraphQLSpecifiedByDirective,
GraphQLType,
GraphQLUnionType,
GraphQLUnionTypeKwargs,
assert_schema,
introspection_types,
is_enum_type,
Expand Down Expand Up @@ -326,7 +330,7 @@ def extend_named_type(self, type_: GraphQLNamedType) -> GraphQLNamedType:
raise TypeError(msg) # pragma: no cover

def extend_input_object_type_fields(
self, kwargs: dict[str, Any], extensions: tuple[Any, ...]
self, kwargs: GraphQLInputObjectTypeKwargs, extensions: tuple[Any, ...]
) -> GraphQLInputFieldMap:
"""Extend GraphQL input object type fields."""
return {
Expand Down Expand Up @@ -392,7 +396,7 @@ def extend_scalar_type(self, type_: GraphQLScalarType) -> GraphQLScalarType:
)

def extend_object_type_interfaces(
self, kwargs: dict[str, Any], extensions: tuple[Any, ...]
self, kwargs: GraphQLObjectTypeKwargs, extensions: tuple[Any, ...]
) -> list[GraphQLInterfaceType]:
"""Extend a GraphQL object type interface."""
return [
Expand All @@ -401,7 +405,7 @@ def extend_object_type_interfaces(
] + self.build_interfaces(extensions)

def extend_object_type_fields(
self, kwargs: dict[str, Any], extensions: tuple[Any, ...]
self, kwargs: GraphQLObjectTypeKwargs, extensions: tuple[Any, ...]
) -> GraphQLFieldMap:
"""Extend GraphQL object type fields."""
return {
Expand Down Expand Up @@ -430,7 +434,7 @@ def extend_object_type(self, type_: GraphQLObjectType) -> GraphQLObjectType:
)

def extend_interface_type_interfaces(
self, kwargs: dict[str, Any], extensions: tuple[Any, ...]
self, kwargs: GraphQLInterfaceTypeKwargs, extensions: tuple[Any, ...]
) -> list[GraphQLInterfaceType]:
"""Extend GraphQL interface type interfaces."""
return [
Expand All @@ -439,7 +443,7 @@ def extend_interface_type_interfaces(
] + self.build_interfaces(extensions)

def extend_interface_type_fields(
self, kwargs: dict[str, Any], extensions: tuple[Any, ...]
self, kwargs: GraphQLInterfaceTypeKwargs, extensions: tuple[Any, ...]
) -> GraphQLFieldMap:
"""Extend GraphQL interface type fields."""
return {
Expand Down Expand Up @@ -470,7 +474,7 @@ def extend_interface_type(
)

def extend_union_type_types(
self, kwargs: dict[str, Any], extensions: tuple[Any, ...]
self, kwargs: GraphQLUnionTypeKwargs, extensions: tuple[Any, ...]
) -> list[GraphQLObjectType]:
"""Extend types of a GraphQL union type."""
return [
Expand Down
20 changes: 10 additions & 10 deletions tests/type/test_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,35 +714,35 @@ def defines_an_enum_using_an_enum_value_map():
assert enum_type.values == {"RED": red, "BLUE": blue}

def defines_an_enum_using_a_python_enum():
colors = Enum("Colors", "RED BLUE")
enum_type = GraphQLEnumType("SomeEnum", colors)
Colors = Enum("Colors", "RED BLUE")
enum_type = GraphQLEnumType("SomeEnum", Colors)
assert enum_type.values == {
"RED": GraphQLEnumValue(1),
"BLUE": GraphQLEnumValue(2),
}

def defines_an_enum_using_values_of_a_python_enum():
colors = Enum("Colors", "RED BLUE")
enum_type = GraphQLEnumType("SomeEnum", colors, names_as_values=False)
Colors = Enum("Colors", "RED BLUE")
enum_type = GraphQLEnumType("SomeEnum", Colors, names_as_values=False)
assert enum_type.values == {
"RED": GraphQLEnumValue(1),
"BLUE": GraphQLEnumValue(2),
}

def defines_an_enum_using_names_of_a_python_enum():
colors = Enum("Colors", "RED BLUE")
enum_type = GraphQLEnumType("SomeEnum", colors, names_as_values=True)
Colors = Enum("Colors", "RED BLUE")
enum_type = GraphQLEnumType("SomeEnum", Colors, names_as_values=True)
assert enum_type.values == {
"RED": GraphQLEnumValue("RED"),
"BLUE": GraphQLEnumValue("BLUE"),
}

def defines_an_enum_using_members_of_a_python_enum():
colors = Enum("Colors", "RED BLUE")
enum_type = GraphQLEnumType("SomeEnum", colors, names_as_values=None)
Colors = Enum("Colors", "RED BLUE")
enum_type = GraphQLEnumType("SomeEnum", Colors, names_as_values=None)
assert enum_type.values == {
"RED": GraphQLEnumValue(colors.RED),
"BLUE": GraphQLEnumValue(colors.BLUE),
"RED": GraphQLEnumValue(Colors.RED),
"BLUE": GraphQLEnumValue(Colors.BLUE),
}

def defines_an_enum_type_with_a_description():
Expand Down
12 changes: 6 additions & 6 deletions tests/validation/harness.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

from graphql.language import parse
from graphql.utilities import build_schema
Expand All @@ -9,7 +9,7 @@
if TYPE_CHECKING:
from graphql.error import GraphQLError
from graphql.type import GraphQLSchema
from graphql.validation import SDLValidationRule, ValidationRule
from graphql.validation import ASTValidationRule

__all__ = [
"test_schema",
Expand Down Expand Up @@ -125,9 +125,9 @@


def assert_validation_errors(
rule: type[ValidationRule],
rule: type[ASTValidationRule],
query_str: str,
errors: list[GraphQLError],
errors: list[GraphQLError | dict[str, Any]],
schema: GraphQLSchema = test_schema,
) -> list[GraphQLError]:
doc = parse(query_str)
Expand All @@ -137,9 +137,9 @@ def assert_validation_errors(


def assert_sdl_validation_errors(
rule: type[SDLValidationRule],
rule: type[ASTValidationRule],
sdl_str: str,
errors: list[GraphQLError],
errors: list[GraphQLError | dict[str, Any]],
schema: GraphQLSchema | None = None,
) -> list[GraphQLError]:
doc = parse(sdl_str)
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ python =

[testenv:ruff]
basepython = python3.12
deps = ruff>=0.5.1,<0.6
deps = ruff>=0.5.3,<0.6
commands =
ruff check src tests
ruff format --check src tests
Expand All @@ -26,7 +26,7 @@ commands =
basepython = python3.12
deps =
mypy>=1.10,<2
pytest>=8.2,<9
pytest>=8.3,<9
commands =
mypy src tests

Expand Down

0 comments on commit 730ac15

Please sign in to comment.