diff options
author | John Aslanides <jaslanides@google.com> | 2022-05-23 10:30:17 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-05-23 10:30:43 -0700 |
commit | 18171acc6f67acd1a14e8f2ad58318ea80410137 (patch) | |
tree | e073ffe4d720a0783d1a464310bb35ae24053d7d /absl | |
parent | 89159550c75bee435683a690a572381937d9a4e5 (diff) | |
download | absl-py-18171acc6f67acd1a14e8f2ad58318ea80410137.tar.gz |
Make FlagHolder unconditionally generic.
Now that we've dropped Python 2 support, we can drop the conditional import of `typing`.
PiperOrigin-RevId: 450471818
Change-Id: I6c4efc7b6943b9794b2a3cf1eba90d330d6b73fd
Diffstat (limited to 'absl')
-rw-r--r-- | absl/flags/_flagvalues.py | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/absl/flags/_flagvalues.py b/absl/flags/_flagvalues.py index 443524c..1b54fb3 100644 --- a/absl/flags/_flagvalues.py +++ b/absl/flags/_flagvalues.py @@ -22,6 +22,7 @@ import itertools import logging import os import sys +from typing import Generic, TypeVar from xml.dom import minidom from absl.flags import _exceptions @@ -29,19 +30,13 @@ from absl.flags import _flag from absl.flags import _helpers from absl.flags import _validators_classes -# pylint: disable=unused-import -try: - import typing - from typing import Text, Optional -except ImportError: - typing = None -# pylint: enable=unused-import - # Add flagvalues module to disclaimed module ids. _helpers.disclaim_module_ids.add(id(sys.modules[__name__])) +_T = TypeVar('_T') + -class FlagValues(object): +class FlagValues: """Registry of 'Flag' objects. A 'FlagValues' can then scan command line arguments, passing flag @@ -1297,14 +1292,8 @@ class FlagValues(object): FLAGS = FlagValues() -if typing: - _T = typing.TypeVar('_T') - _Base = typing.Generic[_T] -else: - _Base = object - -class FlagHolder(_Base): +class FlagHolder(Generic[_T]): """Holds a defined flag. This facilitates a cleaner api around global state. Instead of |