Skip to content

Commit

Permalink
Update mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Feb 8, 2024
1 parent 4d240d4 commit 37f8eb2
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install "tox>=4.12,<5" "tox-gh-actions>=3.2,<4"
pip install "tox>=3.28,<5" "tox-gh-actions>=3.2,<4"
- name: Run unit tests with tox
run: tox
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GraphQL-core 3

GraphQL-core 3 is a Python 3.7+ port of [GraphQL.js](https://github.com/graphql/graphql-js),
GraphQL-core 3 is a Python 3.6+ port of [GraphQL.js](https://github.com/graphql/graphql-js),
the JavaScript reference implementation for [GraphQL](https://graphql.org/),
a query language for APIs created by Facebook.

Expand Down Expand Up @@ -203,7 +203,7 @@ Design goals for the GraphQL-core 3 library were:

Some restrictions (mostly in line with the design goals):

* requires Python 3.7 or newer
* requires Python 3.6 or newer (Python 3.7 and newer in latest version)
* does not support some already deprecated methods and options of GraphQL.js
* supports asynchronous operations only via async.io
(does not support the additional executors in GraphQL-core)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ optional = true

[tool.poetry.group.lint.dependencies]
ruff = ">=0.2,<0.3"
mypy = "1.3.0"
mypy = "1.8.0"
bump2version = ">=1.0,<2"

[tool.poetry.group.doc]
Expand Down
8 changes: 3 additions & 5 deletions src/graphql/execution/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,7 @@ def execute(
raise GraphQLError(UNEXPECTED_MULTIPLE_PAYLOADS)

async def await_result() -> Any:
awaited_result = await result # type: ignore
awaited_result = await result
if isinstance(awaited_result, ExecutionResult):
return awaited_result
return ExecutionResult(
Expand Down Expand Up @@ -2388,7 +2388,7 @@ def subscribe(
return map_async_iterable(result, ensure_single_execution_result)

async def await_result() -> Union[AsyncIterator[ExecutionResult], ExecutionResult]:
result_or_iterable = await result # type: ignore
result_or_iterable = await result
if isinstance(result_or_iterable, AsyncIterable):
return map_async_iterable(
result_or_iterable, ensure_single_execution_result
Expand Down Expand Up @@ -2496,9 +2496,7 @@ async def await_result() -> Any:
awaited_result_or_stream = await result_or_stream # type: ignore
if isinstance(awaited_result_or_stream, ExecutionResult):
return awaited_result_or_stream
return context.map_source_to_response( # type: ignore
awaited_result_or_stream
)
return context.map_source_to_response(awaited_result_or_stream)

return await_result()

Expand Down
2 changes: 1 addition & 1 deletion src/graphql/type/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ def __init__(
isinstance(name, str) for name in values
):
try:
values = dict(values) # type: ignore
values = dict(values)
except (TypeError, ValueError) as error:
msg = (
f"{name} values must be an Enum or a mapping"
Expand Down
14 changes: 7 additions & 7 deletions src/graphql/utilities/strip_ignored_characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def strip_ignored_characters(source: Union[str, Source]) -> str:
"""Strip characters that are ignored anyway.
'''Strip characters that are ignored anyway.
Strips characters that are not significant to the validity or execution
of a GraphQL document:
Expand Down Expand Up @@ -51,20 +51,20 @@ def strip_ignored_characters(source: Union[str, Source]) -> str:
SDL example::
\"\"\"
"""
Type description
\"\"\"
"""
type Foo {
\"\"\"
"""
Field description
\"\"\"
"""
bar: String
}
Becomes::
\"\"\"Type description\"\"\" type Foo{\"\"\"Field description\"\"\" bar:String}
"""
"""Type description""" type Foo{"""Field description""" bar:String}
'''
if not is_source(source):
source = Source(cast(str, source))

Expand Down
2 changes: 1 addition & 1 deletion src/graphql/validation/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def validate(
errors: List[GraphQLError] = []

def on_error(error: GraphQLError) -> None:
if len(errors) >= max_errors: # type: ignore
if len(errors) >= max_errors:
raise validation_aborted_error
errors.append(error)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_user_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,13 @@ async def mutate_users():
)

async def receive_one():
async for result in subscription_one: # type: ignore # pragma: no cover
async for result in subscription_one: # pragma: no cover
received_one.append(result)
if len(received_one) == 3: # pragma: no cover else
break

async def receive_all():
async for result in subscription_all: # type: ignore # pragma: no cover
async for result in subscription_all: # pragma: no cover
received_all.append(result)
if len(received_all) == 6: # pragma: no cover else
break
Expand Down
4 changes: 2 additions & 2 deletions tests/type/test_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ def defines_an_enum_type_with_a_description():
description = "nice enum"
enum_type = GraphQLEnumType(
"SomeEnum",
{}, # type: ignore
{},
description=description,
)
assert enum_type.description is description
Expand Down Expand Up @@ -887,7 +887,7 @@ def accepts_an_enum_type_with_ast_node_and_extension_ast_nodes():
extension_ast_nodes = [EnumTypeExtensionNode()]
enum_type = GraphQLEnumType(
"SomeEnum",
{}, # type: ignore
{},
ast_node=ast_node,
extension_ast_nodes=extension_ast_nodes,
)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ commands =
[testenv:mypy]
basepython = python3.11
deps =
mypy==1.3.0
mypy==1.8.0
pytest>=7.3,<8
commands =
mypy src tests
Expand Down

0 comments on commit 37f8eb2

Please sign in to comment.