Convert Python type hinting to be PEP-585 Compliant (#4083)

Python [PEP-585](https://peps.python.org/pep-0585/) replaces a number of
`typing` module types with built-in equivalents and `collections.abc`
versions as of Python 3.9, with the aim of eventually removing the
`typing` module versions of these classes altogether. Since the minimum
required version of Python listed in the [Contribution Tools
document](https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/contribution_tools.md#main-tools)
is 3.9, the type hints in the various python files in the repo can be
updated to this style of type hint without a need for backwards
compatibility.

Feel free to close if this isn't a desired change at this time!

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Jack McCluskey
2024-06-26 19:32:37 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent 5a8dfda4f0
commit 319c3caf99
7 changed files with 54 additions and 52 deletions
+6 -5
View File
@@ -10,8 +10,9 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""
import argparse
from collections.abc import Generator
import os
from typing import Dict, Generator, Optional, Tuple
from typing import Optional
# https://pypi.org/project/gql/
import gql # type: ignore
@@ -54,16 +55,16 @@ class Client:
)
self._client = gql.Client(transport=transport)
def execute(self, query: str) -> Dict:
def execute(self, query: str) -> dict:
"""Runs a query."""
return self._client.execute(gql.gql(query)) # type: ignore
def execute_and_paginate(
self,
query: str,
path: Tuple[str, ...],
first_page: Optional[Dict] = None,
) -> Generator[Dict, None, None]:
path: tuple[str, ...],
first_page: Optional[dict] = None,
) -> Generator[dict, None, None]:
"""Runs a query with pagination.
Arguments: