From: Nicholas Nethercote Date: Wed, 22 Mar 2023 22:50:21 +0000 (+1100) Subject: Make `cg_annotate` work with Python 3.9, by avoiding `TypeAlias`. X-Git-Tag: VALGRIND_3_21_0~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9e7b663fb69075a110963d85726389f469fcf5b;p=thirdparty%2Fvalgrind.git Make `cg_annotate` work with Python 3.9, by avoiding `TypeAlias`. --- diff --git a/cachegrind/cg_annotate.in b/cachegrind/cg_annotate.in index 91d75aecdf..20969f0f92 100755 --- a/cachegrind/cg_annotate.in +++ b/cachegrind/cg_annotate.in @@ -34,6 +34,10 @@ This script reads Cachegrind output files and produces human-readable reports. # formatters, type-checkers, and linters on `cg_annotate.in` and then generates # `cg_annotate`. # +# Python versions: Currently this script targets Python 3.9 and later versions. +# Consequences of this: +# - No use of `TypeAlias` for explicit type aliases, which requires 3.10. +# # The following Python tools are used. All can be installed with `pip3 install # $NAME`, except `cProfile` which is built into Python. # @@ -73,7 +77,7 @@ import re import sys from argparse import ArgumentParser, BooleanOptionalAction, Namespace from collections import defaultdict -from typing import Callable, DefaultDict, NewType, NoReturn, TextIO, TypeAlias +from typing import Callable, DefaultDict, NewType, NoReturn, TextIO class Args(Namespace): @@ -323,11 +327,13 @@ class Cc: Flfn = NewType("Flfn", tuple[str, str]) # Per-function CCs. -DictFlfnCc: TypeAlias = DefaultDict[Flfn, Cc] +# Note: not using `TypeAlias`. See "Python versions" comment above. +DictFlfnCc = DefaultDict[Flfn, Cc] # Per-line CCs, organised by filename and line number. -DictLineCc: TypeAlias = DefaultDict[int, Cc] -DictFlDictLineCc: TypeAlias = DefaultDict[str, DictLineCc] +# Note: not using `TypeAlias`. See "Python versions" comment above. +DictLineCc = DefaultDict[int, Cc] +DictFlDictLineCc = DefaultDict[str, DictLineCc] def die(msg: str) -> NoReturn: