|
From: Nicholas N. <nj...@so...> - 2023-03-22 22:51:47
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=e9e7b663fb69075a110963d85726389f469fcf5b commit e9e7b663fb69075a110963d85726389f469fcf5b Author: Nicholas Nethercote <n.n...@gm...> Date: Thu Mar 23 09:50:21 2023 +1100 Make `cg_annotate` work with Python 3.9, by avoiding `TypeAlias`. Diff: --- cachegrind/cg_annotate.in | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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: |