diff options
author | Mike Frysinger <vapier@google.com> | 2023-06-09 15:29:57 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-06-09 15:29:57 +0000 |
commit | 121b6775f79a77ff50dacc59b54010ce372eda3f (patch) | |
tree | 3c4392fe4bba3066f89b01da31494cd05daeaaaa | |
parent | de52b8bff7a9be8939609eb777b8c91c0a70b6a4 (diff) | |
parent | 4e5df0b0abfda83049eba1eb202ce85bceb6f58d (diff) | |
download | repohooks-121b6775f79a77ff50dacc59b54010ce372eda3f.tar.gz |
switch from collections.namedtuple to typing.NamedTuple am: 4e5df0b0ab
Original change: https://android-review.googlesource.com/c/platform/tools/repohooks/+/2620891
Change-Id: Ia1bef75879322216fa8876b2d1e58dd45984f011
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | rh/__init__.py | 12 | ||||
-rw-r--r-- | rh/hooks.py | 9 |
2 files changed, 15 insertions, 6 deletions
diff --git a/rh/__init__.py b/rh/__init__.py index 91a106c..2b1676e 100644 --- a/rh/__init__.py +++ b/rh/__init__.py @@ -14,8 +14,14 @@ """Common repohook objects/constants.""" -import collections +from typing import NamedTuple -# An object representing the git project that we're testing currently. -Project = collections.namedtuple('Project', ['name', 'dir']) +class Project(NamedTuple): + """The git project that we're testing currently.""" + + # The name of the project. + name: str + + # Absolute path to the project checkout. + dir: str diff --git a/rh/hooks.py b/rh/hooks.py index 47c3adb..c3e6e79 100644 --- a/rh/hooks.py +++ b/rh/hooks.py @@ -14,13 +14,13 @@ """Functions that implement the actual checks.""" -import collections import fnmatch import json import os import platform import re import sys +from typing import Callable, NamedTuple _path = os.path.realpath(__file__ + '/../..') if sys.path[0] != _path: @@ -243,8 +243,11 @@ class HookOptions(object): return self.expand_vars([tool_path])[0] -# A callable hook. -CallableHook = collections.namedtuple('CallableHook', ('name', 'hook', 'scope')) +class CallableHook(NamedTuple): + """A callable hook.""" + name: str + hook: Callable + scope: ExclusionScope def _run(cmd, **kwargs): |