Skip to content

Commit

Permalink
Remove additional checks for sys.version_info
Browse files Browse the repository at this point in the history
  • Loading branch information
dbieber committed Sep 20, 2024
1 parent c235876 commit 3dbb005
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 19 deletions.
2 changes: 0 additions & 2 deletions fire/fire_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 1 addition & 4 deletions fire/helptext.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import collections
import itertools
import sys

from fire import completion
from fire import custom_descriptions
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 0 additions & 13 deletions fire/helptext_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""Tests for the helptext module."""

import os
import sys
import textwrap

from fire import formatting
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions fire/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
else:
_StrNode = ast.Constant


def CreateParser():
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('--verbose', '-v', action='store_true')
Expand Down

0 comments on commit 3dbb005

Please sign in to comment.