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
+7 -7
View File
@@ -129,7 +129,7 @@ class _Comment:
self.body = body
@staticmethod
def from_raw_comment(raw_comment: dict) -> "_Comment":
def from_raw_comment(raw_comment: dict[str, Any]) -> "_Comment":
"""Creates the comment from a raw comment dict."""
return _Comment(
raw_comment["author"]["login"],
@@ -176,7 +176,7 @@ class _Comment:
class _PRComment(_Comment):
"""A comment on the top-level PR."""
def __init__(self, raw_comment: dict):
def __init__(self, raw_comment: dict[str, Any]):
super().__init__(
raw_comment["author"]["login"],
raw_comment["createdAt"],
@@ -195,7 +195,7 @@ class _PRComment(_Comment):
class _Thread:
"""A review thread on a line of code."""
def __init__(self, parsed_args: argparse.Namespace, thread: dict):
def __init__(self, parsed_args: argparse.Namespace, thread: dict[str, Any]):
self.is_resolved: bool = thread["isResolved"]
comments = thread["comments"]["nodes"]
@@ -347,7 +347,7 @@ def _query(
def _accumulate_pr_comment(
parsed_args: argparse.Namespace,
comments: list[_PRComment],
raw_comment: dict,
raw_comment: dict[str, Any],
) -> None:
"""Collects top-level comments and reviews."""
# Elide reviews that have no top-level comment body.
@@ -358,7 +358,7 @@ def _accumulate_pr_comment(
def _accumulate_thread(
parsed_args: argparse.Namespace,
threads_by_path: dict[str, list[_Thread]],
raw_thread: dict,
raw_thread: dict[str, Any],
) -> None:
"""Adds threads to threads_by_path for later sorting."""
thread = _Thread(parsed_args, raw_thread)
@@ -387,10 +387,10 @@ def _accumulate_thread(
def _paginate(
field_name: str,
accumulator: Callable[[argparse.Namespace, Any, dict], None],
accumulator: Callable[[argparse.Namespace, Any, dict[str, Any]], None],
parsed_args: argparse.Namespace,
client: github_helpers.Client,
main_result: dict,
main_result: dict[str, Any],
output: Any,
) -> None:
"""Paginates through the given field_name, accumulating results."""