From 527e3d056ecc134531f1ef3ed45d46581b5844b9 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 13 Feb 2023 14:20:46 -0500 Subject: [PATCH 1/8] Fix typos in console and tests (#436) --- fire/console/console_attr.py | 6 +++--- fire/console/console_attr_os.py | 2 +- fire/console/console_pager.py | 2 +- fire/docstrings_test.py | 12 ++++++------ fire/parser_test.py | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fire/console/console_attr.py b/fire/console/console_attr.py index f88d5788..815e16b8 100644 --- a/fire/console/console_attr.py +++ b/fire/console/console_attr.py @@ -268,7 +268,7 @@ def __init__(self, encoding=None, suppress_output=False): # ANSI "standard" attributes. if self.SupportsAnsi(): - # Select Graphic Rendition paramaters from + # Select Graphic Rendition parameters from # http://en.wikipedia.org/wiki/ANSI_escape_code#graphics # Italic '3' would be nice here but its not widely supported. self._csi = '\x1b[' @@ -394,7 +394,7 @@ def GetControlSequenceIndicator(self): """Returns the control sequence indicator string. Returns: - The conrol sequence indicator string or None if control sequences are not + The control sequence indicator string or None if control sequences are not supported. """ return self._csi @@ -408,7 +408,7 @@ def GetControlSequenceLen(self, buf): buf: The string to check for a control sequence. Returns: - The conrol sequence length at the beginning of buf or 0 if buf does not + The control sequence length at the beginning of buf or 0 if buf does not start with a control sequence. """ if not self._csi or not buf.startswith(self._csi): diff --git a/fire/console/console_attr_os.py b/fire/console/console_attr_os.py index 8482c7bc..869c5949 100644 --- a/fire/console/console_attr_os.py +++ b/fire/console/console_attr_os.py @@ -123,7 +123,7 @@ def _GetTermSizeEnvironment(): def _GetTermSizeTput(): - """Returns the terminal x and y dimemsions from tput(1).""" + """Returns the terminal x and y dimensions from tput(1).""" import subprocess # pylint: disable=g-import-not-at-top output = encoding.Decode(subprocess.check_output(['tput', 'cols'], stderr=subprocess.STDOUT)) diff --git a/fire/console/console_pager.py b/fire/console/console_pager.py index 044fcb37..565c7e1e 100644 --- a/fire/console/console_pager.py +++ b/fire/console/console_pager.py @@ -94,7 +94,7 @@ def __init__(self, contents, out=None, prompt=None): Args: contents: The entire contents of the text lines to page. out: The output stream, log.out (effectively) if None. - prompt: The page break prompt, a defalt prompt is used if None.. + prompt: The page break prompt, a default prompt is used if None.. """ self._contents = contents self._out = out or sys.stdout diff --git a/fire/docstrings_test.py b/fire/docstrings_test.py index 2328ef16..0d6e5d18 100644 --- a/fire/docstrings_test.py +++ b/fire/docstrings_test.py @@ -50,12 +50,12 @@ def test_one_line_simple_whitespace(self): def test_one_line_too_long(self): # pylint: disable=line-too-long - docstring = """A one line docstring thats both a little too verbose and a little too long so it keeps going well beyond a reasonable length for a one-liner. + docstring = """A one line docstring that is both a little too verbose and a little too long so it keeps going well beyond a reasonable length for a one-liner. """ # pylint: enable=line-too-long docstring_info = docstrings.parse(docstring) expected_docstring_info = DocstringInfo( - summary='A one line docstring thats both a little too verbose and ' + summary='A one line docstring that is both a little too verbose and ' 'a little too long so it keeps going well beyond a reasonable length ' 'for a one-liner.', ) @@ -63,25 +63,25 @@ def test_one_line_too_long(self): def test_one_line_runs_over(self): # pylint: disable=line-too-long - docstring = """A one line docstring thats both a little too verbose and a little too long + docstring = """A one line docstring that is both a little too verbose and a little too long so it runs onto a second line. """ # pylint: enable=line-too-long docstring_info = docstrings.parse(docstring) expected_docstring_info = DocstringInfo( - summary='A one line docstring thats both a little too verbose and ' + summary='A one line docstring that is both a little too verbose and ' 'a little too long so it runs onto a second line.', ) self.assertEqual(expected_docstring_info, docstring_info) def test_one_line_runs_over_whitespace(self): docstring = """ - A one line docstring thats both a little too verbose and a little too long + A one line docstring that is both a little too verbose and a little too long so it runs onto a second line. """ docstring_info = docstrings.parse(docstring) expected_docstring_info = DocstringInfo( - summary='A one line docstring thats both a little too verbose and ' + summary='A one line docstring that is both a little too verbose and ' 'a little too long so it runs onto a second line.', ) self.assertEqual(expected_docstring_info, docstring_info) diff --git a/fire/parser_test.py b/fire/parser_test.py index 0257be28..6b6b79b1 100644 --- a/fire/parser_test.py +++ b/fire/parser_test.py @@ -117,8 +117,8 @@ def testDefaultParseValueBareWordsTuple(self): def testDefaultParseValueNestedContainers(self): self.assertEqual( - parser.DefaultParseValue('[(A, 2, "3"), 5, {alph: 10.2, beta: "cat"}]'), - [('A', 2, '3'), 5, {'alph': 10.2, 'beta': 'cat'}]) + parser.DefaultParseValue('[(A, 2, "3"), 5, {alpha: 10.2, beta: "cat"}]'), + [('A', 2, '3'), 5, {'alpha': 10.2, 'beta': 'cat'}]) def testDefaultParseValueComments(self): self.assertEqual(parser.DefaultParseValue('"0#comments"'), '0#comments') From 6e485c971f4998175b841c775edcd980f2fb55ea Mon Sep 17 00:00:00 2001 From: David Bieber Date: Mon, 13 Feb 2023 15:24:46 -0500 Subject: [PATCH 2/8] Split too long line, fixing lint #437 --- fire/parser_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fire/parser_test.py b/fire/parser_test.py index 6b6b79b1..8aeabc61 100644 --- a/fire/parser_test.py +++ b/fire/parser_test.py @@ -117,7 +117,8 @@ def testDefaultParseValueBareWordsTuple(self): def testDefaultParseValueNestedContainers(self): self.assertEqual( - parser.DefaultParseValue('[(A, 2, "3"), 5, {alpha: 10.2, beta: "cat"}]'), + parser.DefaultParseValue( + '[(A, 2, "3"), 5, {alpha: 10.2, beta: "cat"}]'), [('A', 2, '3'), 5, {'alpha': 10.2, 'beta': 'cat'}]) def testDefaultParseValueComments(self): From 1bcb5d1a265ed78e02b57174171aae9d813dbcf5 Mon Sep 17 00:00:00 2001 From: Panagiotis Simakis Date: Thu, 5 Oct 2023 18:39:58 +0300 Subject: [PATCH 3/8] Add missing parameter description (#462) --- fire/core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fire/core.py b/fire/core.py index c1e97367..6367262d 100644 --- a/fire/core.py +++ b/fire/core.py @@ -94,6 +94,8 @@ def Fire(component=None, command=None, name=None, serialize=None): a string or a list of strings; a list of strings is preferred. name: Optional. The name of the command as entered at the command line. Used in interactive mode and for generating the completion script. + serialize: Optional. If supplied, all objects are serialized to text via + the provided callable. Returns: The result of executing the Fire command. Execution begins with the initial target component. The component is updated by using the command arguments From d44d33d4ac9389854b046ca0270c112693b309e6 Mon Sep 17 00:00:00 2001 From: Max <4649120+maximehk@users.noreply.github.com> Date: Mon, 13 Nov 2023 19:49:58 +0100 Subject: [PATCH 4/8] Fix missing `$` sign in bash completion (#472) Related issue https://github.com/google/python-fire/issues/64 Co-authored-by: Max Hacker --- fire/completion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fire/completion.py b/fire/completion.py index 9659ec6a..4393880d 100644 --- a/fire/completion.py +++ b/fire/completion.py @@ -104,7 +104,7 @@ def _BashScript(name, commands, default_options=None): option_already_entered() {{ local opt - for opt in ${{COMP_WORDS[@]:0:COMP_CWORD}} + for opt in ${{COMP_WORDS[@]:0:$COMP_CWORD}} do if [ $1 == $opt ]; then return 0 From 1d8a137893222b977fc23764ad6e56293cf83a32 Mon Sep 17 00:00:00 2001 From: Hai Zhu <35182391+cocolato@users.noreply.github.com> Date: Wed, 3 Jan 2024 04:25:30 +0800 Subject: [PATCH 5/8] remove asyncio.coroutine (#440) --- fire/test_components_py3.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fire/test_components_py3.py b/fire/test_components_py3.py index 5140921d..17fb932c 100644 --- a/fire/test_components_py3.py +++ b/fire/test_components_py3.py @@ -57,8 +57,7 @@ def lru_cache_decorated(arg1): class WithAsyncio(object): - @asyncio.coroutine - def double(self, count=0): + async def double(self, count=0): return 2 * count From ffb8121ab8d342bad2e613df41fe406b2ed5e133 Mon Sep 17 00:00:00 2001 From: David Bieber Date: Tue, 2 Jan 2024 15:45:49 -0500 Subject: [PATCH 6/8] Update build.yml dropping Python 2.7 (#479) We'll want to reenable later. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9bf78e8b..9864ae98 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: ["2.7", "3.5", "3.7", "3.8", "3.9", "3.10"] + python-version: ["3.5", "3.7", "3.8", "3.9", "3.10"] steps: # Checkout the repo. From 8a41c91a474209b38d58839437f5711190fd3cee Mon Sep 17 00:00:00 2001 From: eXcript Date: Tue, 9 Jan 2024 15:22:03 -0300 Subject: [PATCH 7/8] Update formatting_windows.py (#477) Add a check if 'isatty' member exists in the object, required for packaging with PyInstaller. --- fire/formatting_windows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fire/formatting_windows.py b/fire/formatting_windows.py index 2b85820d..4bcf82e0 100644 --- a/fire/formatting_windows.py +++ b/fire/formatting_windows.py @@ -35,7 +35,7 @@ def initialize_or_disable(): """Enables ANSI processing on Windows or disables it as needed.""" if HAS_COLORAMA: wrap = True - if sys.stdout.isatty() and platform.release() == '10': + if hasattr(sys.stdout, "isatty") and sys.stdout.isatty() and platform.release() == '10': # Enables native ANSI sequences in console. # Windows 10, 2016, and 2019 only. From 343e6b6cec2d174d511e99dec7e5a24849121c2e Mon Sep 17 00:00:00 2001 From: David Bieber Date: Sat, 24 Feb 2024 13:07:41 -0500 Subject: [PATCH 8/8] Add Python 3.11 and Python 3.12 to build workflow (#485) This change brings github actions back into the green. --- .github/scripts/requirements.txt | 11 +++++++---- .github/workflows/build.yml | 2 +- fire/__init__.py | 2 +- fire/__main__.py | 2 +- fire/console/encoding.py | 12 ++++++------ fire/formatting_windows.py | 4 +++- fire/inspectutils.py | 4 ++-- fire/testutils.py | 2 +- pylintrc | 2 +- setup.py | 4 +++- 10 files changed, 26 insertions(+), 19 deletions(-) diff --git a/.github/scripts/requirements.txt b/.github/scripts/requirements.txt index 9e48e20d..13880c9c 100644 --- a/.github/scripts/requirements.txt +++ b/.github/scripts/requirements.txt @@ -1,10 +1,13 @@ -setuptools <65.7.0 -pip <23.0 +setuptools <65.7.0 ; python_version == '2.7' +setuptools <=69.1.1 ; python_version >= '3.8' +pip <23.0 ; python_version == '2.7' +pip ; python_version >= '3.5' pylint <2.15.10 pytest <=7.2.1 pytest-pylint <=1.1.2 pytest-runner <6.0.0 termcolor <2.2.0 hypothesis <6.62.0 -python-Levenshtein <0.20.9 -mock <5.0.0 \ No newline at end of file +python-Levenshtein <0.20.9 ; python_version == '2.7' +levenshtein <=0.25.0 ; python_version >= '3.5' +mock <5.0.0 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9864ae98..eb510f03 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: ["3.5", "3.7", "3.8", "3.9", "3.10"] + python-version: ["3.5", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] steps: # Checkout the repo. diff --git a/fire/__init__.py b/fire/__init__.py index 4cc76210..fae18489 100644 --- a/fire/__init__.py +++ b/fire/__init__.py @@ -21,4 +21,4 @@ from fire.core import Fire __all__ = ['Fire'] -__version__ = '0.5.0' +__version__ = '0.6.0' diff --git a/fire/__main__.py b/fire/__main__.py index 2ad217d6..9d8227ad 100644 --- a/fire/__main__.py +++ b/fire/__main__.py @@ -80,7 +80,7 @@ def import_from_file_path(path): spec.loader.exec_module(module) # pytype: disable=attribute-error else: - import imp # pylint: disable=g-import-not-at-top,import-outside-toplevel,deprecated-module + import imp # pylint: disable=g-import-not-at-top,import-outside-toplevel,deprecated-module,import-error module = imp.load_source(module_name, path) return module, module_name diff --git a/fire/console/encoding.py b/fire/console/encoding.py index 780e5a28..41bda634 100644 --- a/fire/console/encoding.py +++ b/fire/console/encoding.py @@ -86,7 +86,7 @@ def Decode(data, encoding=None): try: # Just return the string if its pure ASCII. - return string.decode('ascii') + return string.decode('ascii') # pytype: disable=attribute-error except UnicodeError: # The string is not ASCII encoded. pass @@ -94,7 +94,7 @@ def Decode(data, encoding=None): # Try the suggested encoding if specified. if encoding: try: - return string.decode(encoding) + return string.decode(encoding) # pytype: disable=attribute-error except UnicodeError: # Bad suggestion. pass @@ -103,21 +103,21 @@ def Decode(data, encoding=None): # be exceptional if a valid extended ascii encoding with extended chars # were also a valid UITF-8 encoding. try: - return string.decode('utf8') + return string.decode('utf8') # pytype: disable=attribute-error except UnicodeError: # Not a UTF-8 encoding. pass # Try the filesystem encoding. try: - return string.decode(sys.getfilesystemencoding()) + return string.decode(sys.getfilesystemencoding()) # pytype: disable=attribute-error except UnicodeError: # string is not encoded for filesystem paths. pass # Try the system default encoding. try: - return string.decode(sys.getdefaultencoding()) + return string.decode(sys.getdefaultencoding()) # pytype: disable=attribute-error except UnicodeError: # string is not encoded using the default encoding. pass @@ -137,7 +137,7 @@ def Decode(data, encoding=None): # string = '\xdc' # string = string.decode('iso-8859-1') # string = string.encode('ascii', 'backslashreplace') - return string.decode('iso-8859-1') + return string.decode('iso-8859-1') # pytype: disable=attribute-error def GetEncodedValue(env, name, default=None): diff --git a/fire/formatting_windows.py b/fire/formatting_windows.py index 4bcf82e0..ce0f677d 100644 --- a/fire/formatting_windows.py +++ b/fire/formatting_windows.py @@ -35,7 +35,9 @@ def initialize_or_disable(): """Enables ANSI processing on Windows or disables it as needed.""" if HAS_COLORAMA: wrap = True - if hasattr(sys.stdout, "isatty") and sys.stdout.isatty() and platform.release() == '10': + if (hasattr(sys.stdout, "isatty") + and sys.stdout.isatty() + and platform.release() == '10'): # Enables native ANSI sequences in console. # Windows 10, 2016, and 2019 only. diff --git a/fire/inspectutils.py b/fire/inspectutils.py index 0fa8e7d3..15f32f91 100644 --- a/fire/inspectutils.py +++ b/fire/inspectutils.py @@ -98,10 +98,10 @@ class with an __init__ method. def Py2GetArgSpec(fn): """A wrapper around getargspec that tries both fn and fn.__call__.""" try: - return inspect.getargspec(fn) # pylint: disable=deprecated-method + return inspect.getargspec(fn) # pylint: disable=deprecated-method,no-member except TypeError: if hasattr(fn, '__call__'): - return inspect.getargspec(fn.__call__) # pylint: disable=deprecated-method + return inspect.getargspec(fn.__call__) # pylint: disable=deprecated-method,no-member raise diff --git a/fire/testutils.py b/fire/testutils.py index ea410e82..5f875147 100644 --- a/fire/testutils.py +++ b/fire/testutils.py @@ -74,7 +74,7 @@ def assertOutputMatches(self, stdout='.*', stderr='.*', capture=True): def assertRaisesRegex(self, *args, **kwargs): # pylint: disable=arguments-differ if sys.version_info.major == 2: - return super(BaseTestCase, self).assertRaisesRegexp(*args, **kwargs) # pylint: disable=deprecated-method + return super(BaseTestCase, self).assertRaisesRegexp(*args, **kwargs) # pylint: disable=deprecated-method,no-member else: return super(BaseTestCase, self).assertRaisesRegex(*args, **kwargs) # pylint: disable=no-member diff --git a/pylintrc b/pylintrc index b89b16d1..558d3ba2 100644 --- a/pylintrc +++ b/pylintrc @@ -32,7 +32,7 @@ enable=indexing-exception,old-raise-syntax # Disable the message, report, category or checker with the given id(s). You # can either give multiple identifier separated by comma (,) or put this option # multiple time. -disable=design,similarities,no-self-use,attribute-defined-outside-init,locally-disabled,star-args,pointless-except,bad-option-value,global-statement,fixme,suppressed-message,useless-suppression,locally-enabled,file-ignored,wrong-import-order,useless-object-inheritance,no-else-return,super-with-arguments,raise-missing-from,consider-using-f-string,unspecified-encoding,unnecessary-lambda-assignment +disable=design,similarities,no-self-use,attribute-defined-outside-init,locally-disabled,star-args,pointless-except,bad-option-value,global-statement,fixme,suppressed-message,useless-suppression,locally-enabled,file-ignored,wrong-import-order,useless-object-inheritance,no-else-return,super-with-arguments,raise-missing-from,consider-using-f-string,unspecified-encoding,unnecessary-lambda-assignment,wrong-import-position,ungrouped-imports,deprecated-module [REPORTS] diff --git a/setup.py b/setup.py index 8e95f414..24e0e325 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ 'python-Levenshtein', ] -VERSION = '0.5.0' +VERSION = '0.6.0' URL = 'https://github.com/google/python-fire' setup( @@ -72,6 +72,8 @@ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Operating System :: OS Independent', 'Operating System :: POSIX',