Skip to content

Commit

Permalink
Replace built-in generic list with typing.List
Browse files Browse the repository at this point in the history
… for compatibility with Python versions before 3.9, which lack PEP 585.

Change-Id: Ib747d709a8762bcf81e23ddbbf6a4ec4a2c4ce97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4762987
Commit-Queue: Dana Dahlstrom <[email protected]>
Reviewed-by: Weilun Shi <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1181199}
  • Loading branch information
dahlstrom-g committed Aug 10, 2023
1 parent 1c38750 commit b9e59b9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/metrics/histograms/generate_flag_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import re
import subprocess
import sys
import typing

# Import the UKM codegen library for its hashing function, which is the same
# hashing function as used for flag names.
Expand All @@ -25,7 +26,7 @@
import pretty_print


def get_entries_from_unit_test(outdir: str) -> list[str]:
def get_entries_from_unit_test(outdir: str) -> typing.List[str]:
"""Returns `<int>` entries reported missing by the 'CheckHistograms' unittest.
"""
subprocess.run(['autoninja', '-C', outdir, 'unit_tests'])
Expand All @@ -38,7 +39,7 @@ def get_entries_from_unit_test(outdir: str) -> list[str]:
return re.findall('<int [^>]*>', run_test_command.stdout)


def get_entries_from_feature_string(feature: str) -> list[str]:
def get_entries_from_feature_string(feature: str) -> typing.List[str]:
"""Generates entries for `feature`."""
entries = []
for suffix in ['disabled', 'enabled']:
Expand All @@ -49,7 +50,7 @@ def get_entries_from_feature_string(feature: str) -> list[str]:
return entries


def add_entries_to_xml(enums_xml: str, entries: list[str]) -> str:
def add_entries_to_xml(enums_xml: str, entries: typing.List[str]) -> str:
"""Adds each of `entries` to `enums_xml` and pretty prints it."""
# Only add entries not already present.
entries = [entry for entry in entries if enums_xml.find(entry) == -1]
Expand Down

0 comments on commit b9e59b9

Please sign in to comment.