Fix typing of TransportQueryError.errors to List[GraphQLError]#587
Fix typing of TransportQueryError.errors to List[GraphQLError]#587magicmark wants to merge 1 commit intographql-python:masterfrom
Conversation
…QLError] - Change `errors` type annotation in `TransportQueryError` from `Optional[List[Any]]` to `Optional[List[GraphQLError]]` - Wrap raw dict payload in `GraphQLError` in `websockets_protocol.py` so all error paths produce `GraphQLError` objects consistently - Update test assertions to use `GraphQLError` attribute access (`.message`, `.extensions`) instead of dict indexing (`["message"]`) - Add `extensions is not None` guards for mypy narrowing This reduces the total mypy error count from 24 to 10 (fixing 14 pre-existing type errors in websocket exception tests). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1a5e2e6 to
23d888a
Compare
|
Closing this PR — after deeper investigation, the typing change isn't correct as-is.
To properly type this as For now, |
Summary
TransportQueryError.errorsfromOptional[List[Any]]toOptional[List[GraphQLError]]in both the class attribute and__init__parameterfrom graphql import GraphQLErrorimport togql/transport/exceptions.pyMotivation
TransportQueryError.errorsis populated fromExecutionResult.errors(from graphql-core), which is typed aslist[GraphQLError] | None. The currentList[Any]annotation loses this type information, making it harder for downstream consumers to work with the errors without casting. This change makes the type annotation accurately reflect the actual data being stored.Test plan
flake8,isort,black, andmypychecks pass on the modified file🤖 Generated with Claude Code