Skip to content

Commit

Permalink
Merge branch 'master' into watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Mar 11, 2024
2 parents e6e7fda + 343e6b6 commit ae1690e
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 35 deletions.
11 changes: 7 additions & 4 deletions .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
python-Levenshtein <0.20.9 ; python_version == '2.7'
levenshtein <=0.25.0 ; python_version >= '3.5'
mock <5.0.0
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Expand Up @@ -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", "3.11", "3.12"]

steps:
# Checkout the repo.
Expand Down
2 changes: 1 addition & 1 deletion fire/__init__.py
Expand Up @@ -21,4 +21,4 @@
from fire.core import Fire

__all__ = ['Fire']
__version__ = '0.5.0'
__version__ = '0.6.0'
2 changes: 1 addition & 1 deletion fire/__main__.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fire/completion.py
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions fire/console/console_attr.py
Expand Up @@ -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['
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion fire/console/console_attr_os.py
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion fire/console/console_pager.py
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions fire/console/encoding.py
Expand Up @@ -86,15 +86,15 @@ 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

# 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
Expand All @@ -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
Expand All @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions fire/core.py
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions fire/docstrings_test.py
Expand Up @@ -50,38 +50,38 @@ 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.',
)
self.assertEqual(expected_docstring_info, docstring_info)

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)
Expand Down
4 changes: 3 additions & 1 deletion fire/formatting_windows.py
Expand Up @@ -35,7 +35,9 @@ 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.

Expand Down
4 changes: 2 additions & 2 deletions fire/inspectutils.py
Expand Up @@ -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


Expand Down
5 changes: 3 additions & 2 deletions fire/parser_test.py
Expand Up @@ -117,8 +117,9 @@ 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')
Expand Down
3 changes: 1 addition & 2 deletions fire/test_components_py3.py
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion fire/testutils.py
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Expand Up @@ -40,7 +40,7 @@
'python-Levenshtein',
]

VERSION = '0.5.0'
VERSION = '0.6.0'
URL = 'https://github.com/google/python-fire'

setup(
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit ae1690e

Please sign in to comment.