Skip to content

Commit efcf60f

Browse files
authored
Lint improvements and type safety (google#558)
* Clean up of lint errors * Always return an element when requested
1 parent 1c43c36 commit efcf60f

File tree

7 files changed

+7
-6
lines changed

7 files changed

+7
-6
lines changed

fire/console/encoding.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def Encode(string, encoding=None):
3333
Returns:
3434
str, The binary string.
3535
"""
36+
del encoding # Unused.
3637
return string
3738

3839

fire/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,5 @@ def GetMetadata(fn):
107107
def GetParseFns(fn):
108108
# type: (...) -> dict
109109
metadata = GetMetadata(fn)
110-
default = {"default": None, "positional": [], "named": {}}
110+
default = {'default': None, 'positional': [], 'named': {}}
111111
return metadata.get(FIRE_PARSE_FNS, default)

fire/formatting_windows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def initialize_or_disable():
3131
"""Enables ANSI processing on Windows or disables it as needed."""
3232
if HAS_COLORAMA:
3333
wrap = True
34-
if (hasattr(sys.stdout, "isatty")
34+
if (hasattr(sys.stdout, 'isatty')
3535
and sys.stdout.isatty()
3636
and platform.release() == '10'):
3737
# Enables native ANSI sequences in console.

fire/helptext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def _CreateFlagItem(flag, docstring_info, spec, required=False,
475475
description = _GetArgDescription(flag, docstring_info)
476476

477477
if not flag_string:
478-
flag_name_upper=formatting.Underline(flag.upper())
478+
flag_name_upper = formatting.Underline(flag.upper())
479479
flag_string = f'--{flag}={flag_name_upper}'
480480
if required:
481481
flag_string += ' (required)'

fire/helptext_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ def testHelpTextMultipleKeywoardArgumentsWithShortArgs(self):
428428
self.assertIn('\n --late', help_screen)
429429

430430

431-
432431
class UsageTest(testutils.BaseTestCase):
433432

434433
def testUsageOutput(self):

fire/test_components.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ def fn_with_kwarg_and_defaults(arg1, arg2, opt=True, **kwargs):
554554
"""
555555
del arg1, arg2, opt
556556
return kwargs.get('arg3')
557-
# pylint: enable=g-doc-args,g-doc-return-or-yield
557+
558558

559559
def fn_with_multiple_defaults(first='first', last='last', late='late'):
560560
"""Function with kwarg and defaults.
@@ -565,3 +565,4 @@ def fn_with_multiple_defaults(first='first', last='last', late='late'):
565565
"""
566566
del last, late
567567
return first
568+
# pylint: enable=g-doc-args,g-doc-return-or-yield

fire/trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def GetLastHealthyElement(self):
7777
for element in reversed(self.elements):
7878
if not element.HasError():
7979
return element
80-
return None
80+
return self.elements[0] # The initial element is always healthy.
8181

8282
def HasError(self):
8383
"""Returns whether the Fire execution encountered a Fire usage error."""

0 commit comments

Comments
 (0)