Skip to content

Commit

Permalink
Lint improvements and type safety (#558)
Browse files Browse the repository at this point in the history
* Clean up of lint errors
* Always return an element when requested
  • Loading branch information
dbieber authored Sep 21, 2024
1 parent 1c43c36 commit efcf60f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions fire/console/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def Encode(string, encoding=None):
Returns:
str, The binary string.
"""
del encoding # Unused.
return string


Expand Down
2 changes: 1 addition & 1 deletion fire/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ def GetMetadata(fn):
def GetParseFns(fn):
# type: (...) -> dict
metadata = GetMetadata(fn)
default = {"default": None, "positional": [], "named": {}}
default = {'default': None, 'positional': [], 'named': {}}
return metadata.get(FIRE_PARSE_FNS, default)
2 changes: 1 addition & 1 deletion fire/formatting_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize_or_disable():
"""Enables ANSI processing on Windows or disables it as needed."""
if HAS_COLORAMA:
wrap = True
if (hasattr(sys.stdout, "isatty")
if (hasattr(sys.stdout, 'isatty')
and sys.stdout.isatty()
and platform.release() == '10'):
# Enables native ANSI sequences in console.
Expand Down
2 changes: 1 addition & 1 deletion fire/helptext.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def _CreateFlagItem(flag, docstring_info, spec, required=False,
description = _GetArgDescription(flag, docstring_info)

if not flag_string:
flag_name_upper=formatting.Underline(flag.upper())
flag_name_upper = formatting.Underline(flag.upper())
flag_string = f'--{flag}={flag_name_upper}'
if required:
flag_string += ' (required)'
Expand Down
1 change: 0 additions & 1 deletion fire/helptext_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ def testHelpTextMultipleKeywoardArgumentsWithShortArgs(self):
self.assertIn('\n --late', help_screen)



class UsageTest(testutils.BaseTestCase):

def testUsageOutput(self):
Expand Down
3 changes: 2 additions & 1 deletion fire/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def fn_with_kwarg_and_defaults(arg1, arg2, opt=True, **kwargs):
"""
del arg1, arg2, opt
return kwargs.get('arg3')
# pylint: enable=g-doc-args,g-doc-return-or-yield


def fn_with_multiple_defaults(first='first', last='last', late='late'):
"""Function with kwarg and defaults.
Expand All @@ -565,3 +565,4 @@ def fn_with_multiple_defaults(first='first', last='last', late='late'):
"""
del last, late
return first
# pylint: enable=g-doc-args,g-doc-return-or-yield
2 changes: 1 addition & 1 deletion fire/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def GetLastHealthyElement(self):
for element in reversed(self.elements):
if not element.HasError():
return element
return None
return self.elements[0] # The initial element is always healthy.

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

0 comments on commit efcf60f

Please sign in to comment.