From 3dbb005bb51bab6aa720e8032833b32b6d125d9f Mon Sep 17 00:00:00 2001 From: David Bieber Date: Thu, 19 Sep 2024 21:03:00 -0400 Subject: [PATCH] Remove additional checks for sys.version_info --- fire/fire_test.py | 2 -- fire/helptext.py | 5 +---- fire/helptext_test.py | 13 ------------- fire/parser.py | 1 + 4 files changed, 2 insertions(+), 19 deletions(-) diff --git a/fire/fire_test.py b/fire/fire_test.py index 74b3bb25..74f1f6e6 100644 --- a/fire/fire_test.py +++ b/fire/fire_test.py @@ -706,8 +706,6 @@ def testClassWithInvalidProperty(self): fire.Fire(tc.InvalidProperty, command=['double', '10']), 20 ) - @testutils.skipIf(sys.version_info[0:2] <= (3, 4), - 'Cannot inspect wrapped signatures in Python 2 or 3.4.') def testHelpKwargsDecorator(self): # Issue #190, follow the wrapped method instead of crashing. with self.assertRaisesFireExit(0): diff --git a/fire/helptext.py b/fire/helptext.py index 93072897..1c0cb626 100644 --- a/fire/helptext.py +++ b/fire/helptext.py @@ -31,7 +31,6 @@ import collections import itertools -import sys from fire import completion from fire import custom_descriptions @@ -533,9 +532,7 @@ def _GetArgType(arg, spec): if arg in spec.annotations: arg_type = spec.annotations[arg] try: - if sys.version_info[0:2] >= (3, 3): - return arg_type.__qualname__ - return arg_type.__name__ + return arg_type.__qualname__ except AttributeError: # Some typing objects, such as typing.Union do not have either a __name__ # or __qualname__ attribute. diff --git a/fire/helptext_test.py b/fire/helptext_test.py index 2250f199..4d35dc0a 100644 --- a/fire/helptext_test.py +++ b/fire/helptext_test.py @@ -15,7 +15,6 @@ """Tests for the helptext module.""" import os -import sys import textwrap from fire import formatting @@ -124,9 +123,6 @@ def testHelpTextFunctionWithKwargsAndDefaults(self): 'Additional undocumented flags may also be accepted.', help_screen) - @testutils.skipIf( - sys.version_info[0:2] < (3, 5), - 'Python < 3.5 does not support type hints.') def testHelpTextFunctionWithDefaultsAndTypes(self): component = ( tc.py3.WithDefaultsAndTypes().double) # pytype: disable=module-attr @@ -141,9 +137,6 @@ def testHelpTextFunctionWithDefaultsAndTypes(self): help_screen) self.assertNotIn('NOTES', help_screen) - @testutils.skipIf( - sys.version_info[0:2] < (3, 5), - 'Python < 3.5 does not support type hints.') def testHelpTextFunctionWithTypesAndDefaultNone(self): component = ( tc.py3.WithDefaultsAndTypes().get_int) # pytype: disable=module-attr @@ -159,9 +152,6 @@ def testHelpTextFunctionWithTypesAndDefaultNone(self): help_screen) self.assertNotIn('NOTES', help_screen) - @testutils.skipIf( - sys.version_info[0:2] < (3, 5), - 'Python < 3.5 does not support type hints.') def testHelpTextFunctionWithTypes(self): component = tc.py3.WithTypes().double # pytype: disable=module-attr help_screen = helptext.HelpText( @@ -177,9 +167,6 @@ def testHelpTextFunctionWithTypes(self): 'NOTES\n You can also use flags syntax for POSITIONAL ARGUMENTS', help_screen) - @testutils.skipIf( - sys.version_info[0:2] < (3, 5), - 'Python < 3.5 does not support type hints.') def testHelpTextFunctionWithLongTypes(self): component = tc.py3.WithTypes().long_type # pytype: disable=module-attr help_screen = helptext.HelpText( diff --git a/fire/parser.py b/fire/parser.py index c4708455..d945b8ce 100644 --- a/fire/parser.py +++ b/fire/parser.py @@ -23,6 +23,7 @@ else: _StrNode = ast.Constant + def CreateParser(): parser = argparse.ArgumentParser(add_help=False) parser.add_argument('--verbose', '-v', action='store_true')