Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint improvements and type safety #558

Merged
merged 2 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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