Fix ty errors for missing generic parameters (#7326)

Mostly these errors were around `dict` missing arguments, and they are
almost always `[str, Any]`.

But a real thorn here was `xml.etree.ElementTree.Element`. `ty` insists
that this is a generic type, and indeed it appears to be one, or
becoming one, in some python version. But it is not generic in python
3.12. So we are stuck in an unsolvable land where:
- `ty` gives an error unless you write `[str]` on the type, because it
thinks it is generic.
- python3.12 gives an error if you do write `[str]` on the type, because
it thinks it is not generic.

Forcing `ty` to target exactly python 3.12 does not help. So I have just
used a linter-ignore comment on that line.
This commit is contained in:
Dana Jansens
2026-06-09 15:08:39 +00:00
committed by GitHub
parent efb78c593c
commit 233a58fcb1
5 changed files with 26 additions and 23 deletions
+6 -6
View File
@@ -12,7 +12,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
import argparse
import os
from collections.abc import Generator
from typing import Optional, cast
from typing import Any, Optional, cast
# https://pypi.org/project/gql/
import gql
@@ -56,11 +56,11 @@ class Client:
self._client = gql.Client(transport=transport)
def execute(
self, query: str, variable_values: Optional[dict] = None
) -> dict:
self, query: str, variable_values: Optional[dict[str, Any]] = None
) -> dict[str, Any]:
"""Runs a query."""
return cast(
dict,
dict[str, Any],
self._client.execute(
gql.gql(query), variable_values=variable_values
),
@@ -70,8 +70,8 @@ class Client:
self,
query: str,
path: tuple[str, ...],
first_page: Optional[dict] = None,
) -> Generator[dict, None, None]:
first_page: Optional[dict[str, Any]] = None,
) -> Generator[dict[str, Any], None, None]:
"""Runs a query with pagination.
Arguments: