Skip to content

Commit

Permalink
Minor typing and linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Jul 7, 2024
1 parent 9f19b40 commit 331c7bc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
5 changes: 1 addition & 4 deletions src/graphql/execution/collect_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,7 @@ def should_include_node(
return False

include = get_directive_values(GraphQLIncludeDirective, node, variable_values)
if include and not include["if"]:
return False

return True
return not (include and not include["if"])


def does_fragment_condition_match(
Expand Down
6 changes: 3 additions & 3 deletions src/graphql/execution/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class ExecutionContext(IncrementalPublisherMixin):
middleware_manager: MiddlewareManager | None

is_awaitable: Callable[[Any], TypeGuard[Awaitable]] = staticmethod(
default_is_awaitable # type: ignore
default_is_awaitable
)

def __init__(
Expand Down Expand Up @@ -1113,13 +1113,13 @@ async def get_completed_results() -> list[Any]:
index = awaitable_indices[0]
completed_results[index] = await completed_results[index]
else:
for index, result in zip(
for index, sub_result in zip(
awaitable_indices,
await gather(
*(completed_results[index] for index in awaitable_indices)
),
):
completed_results[index] = result
completed_results[index] = sub_result
return completed_results

return get_completed_results()
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/language/block_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def is_printable_as_block_string(value: str) -> bool:
if is_empty_line:
return False # has trailing empty lines

if has_common_indent and seen_non_empty_line:
if has_common_indent and seen_non_empty_line: # noqa: SIM103
return False # has internal indent

return True
Expand Down
12 changes: 6 additions & 6 deletions src/graphql/type/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ def fields(self) -> GraphQLFieldMap:
"""Get provided fields, wrapping them as GraphQLFields if needed."""
try:
fields = resolve_thunk(self._fields)
except Exception as error: # noqa: BLE001
except Exception as error:
cls = GraphQLError if isinstance(error, GraphQLError) else TypeError
msg = f"{self.name} fields cannot be resolved. {error}"
raise cls(msg) from error
Expand All @@ -801,7 +801,7 @@ def interfaces(self) -> tuple[GraphQLInterfaceType, ...]:
interfaces: Collection[GraphQLInterfaceType] = resolve_thunk(
self._interfaces # type: ignore
)
except Exception as error: # noqa: BLE001
except Exception as error:
cls = GraphQLError if isinstance(error, GraphQLError) else TypeError
msg = f"{self.name} interfaces cannot be resolved. {error}"
raise cls(msg) from error
Expand Down Expand Up @@ -888,7 +888,7 @@ def fields(self) -> GraphQLFieldMap:
"""Get provided fields, wrapping them as GraphQLFields if needed."""
try:
fields = resolve_thunk(self._fields)
except Exception as error: # noqa: BLE001
except Exception as error:
cls = GraphQLError if isinstance(error, GraphQLError) else TypeError
msg = f"{self.name} fields cannot be resolved. {error}"
raise cls(msg) from error
Expand All @@ -906,7 +906,7 @@ def interfaces(self) -> tuple[GraphQLInterfaceType, ...]:
interfaces: Collection[GraphQLInterfaceType] = resolve_thunk(
self._interfaces # type: ignore
)
except Exception as error: # noqa: BLE001
except Exception as error:
cls = GraphQLError if isinstance(error, GraphQLError) else TypeError
msg = f"{self.name} interfaces cannot be resolved. {error}"
raise cls(msg) from error
Expand Down Expand Up @@ -992,7 +992,7 @@ def types(self) -> tuple[GraphQLObjectType, ...]:
"""Get provided types."""
try:
types: Collection[GraphQLObjectType] = resolve_thunk(self._types)
except Exception as error: # noqa: BLE001
except Exception as error:
cls = GraphQLError if isinstance(error, GraphQLError) else TypeError
msg = f"{self.name} types cannot be resolved. {error}"
raise cls(msg) from error
Expand Down Expand Up @@ -1350,7 +1350,7 @@ def fields(self) -> GraphQLInputFieldMap:
"""Get provided fields, wrap them as GraphQLInputField if needed."""
try:
fields = resolve_thunk(self._fields)
except Exception as error: # noqa: BLE001
except Exception as error:
cls = GraphQLError if isinstance(error, GraphQLError) else TypeError
msg = f"{self.name} fields cannot be resolved. {error}"
raise cls(msg) from error
Expand Down

0 comments on commit 331c7bc

Please sign in to comment.