mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
co-authored by
Jon Ross-Perkins
parent
5a8dfda4f0
commit
319c3caf99
@@ -16,7 +16,7 @@ from multiprocessing import Pool
|
||||
import re
|
||||
import termplotlib as tpl # type:ignore
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional
|
||||
from typing import Optional
|
||||
from dataclasses import dataclass, field, asdict
|
||||
from collections import Counter
|
||||
|
||||
@@ -167,7 +167,7 @@ def scan_file(file: Path) -> Stats:
|
||||
return stats
|
||||
|
||||
|
||||
def parse_args(args: Optional[List[str]] = None) -> argparse.Namespace:
|
||||
def parse_args(args: Optional[list[str]] = None) -> argparse.Namespace:
|
||||
"""Parsers command-line arguments and flags."""
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument(
|
||||
@@ -232,7 +232,7 @@ Fraction IDs: {stats.identifiers / tokens}
|
||||
)
|
||||
|
||||
def print_histogram(
|
||||
title: str, data: Dict[int, int], column_format: str
|
||||
title: str, data: dict[int, int], column_format: str
|
||||
) -> None:
|
||||
print()
|
||||
key_min = min(data.keys())
|
||||
|
||||
Reference in New Issue
Block a user