Skip to content

Commit

Permalink
Merge branch 'master' into ci/builds
Browse files Browse the repository at this point in the history
  • Loading branch information
dbieber authored Sep 21, 2024
2 parents 9757304 + efcf60f commit f6f99fc
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 66 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ jobs:
matrix:
fail-fast: false
os: ["windows-latest", "macos-latest", "ubuntu-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13.0-rc.2"]
include:
# adding some specific/older versions to the matrix
- {os: "ubuntu-20.04", python-version: "3.7"}

steps:
Expand Down
2 changes: 1 addition & 1 deletion fire/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
from fire.core import Fire

__all__ = ['Fire']
__version__ = '0.6.0'
__version__ = '0.7.0'
6 changes: 3 additions & 3 deletions fire/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ def import_from_file_path(path):
"""

if not os.path.exists(path):
raise IOError('Given file path does not exist.')
raise OSError('Given file path does not exist.')

module_name = os.path.basename(path)

spec = util.spec_from_file_location(module_name, path)

if spec is None:
raise IOError('Unable to load module from specified path.')
raise OSError('Unable to load module from specified path.')

module = util.module_from_spec(spec) # pylint: disable=no-member
spec.loader.exec_module(module) # pytype: disable=attribute-error
Expand Down Expand Up @@ -104,7 +104,7 @@ def import_module(module_or_filename):
return import_from_file_path(module_or_filename)

if os.path.sep in module_or_filename: # Use / to detect if it was a filename.
raise IOError('Fire was passed a filename which could not be found.')
raise OSError('Fire was passed a filename which could not be found.')

return import_from_module_name(module_or_filename) # Assume it's a module.

Expand Down
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/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def __init__(self, code, component_trace):
code: (int) Exit code for the Fire CLI.
component_trace: (FireTrace) The trace for the Fire command.
"""
super(FireExit, self).__init__(code)
super().__init__(code)
self.trace = component_trace


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)
12 changes: 6 additions & 6 deletions fire/decorators_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from fire import testutils


class NoDefaults(object):
class NoDefaults:
"""A class for testing decorated functions without default values."""

@decorators.SetParseFns(count=int)
Expand All @@ -40,7 +40,7 @@ def double(count):
return 2 * count


class WithDefaults(object):
class WithDefaults:

@decorators.SetParseFns(float)
def example1(self, arg1=10):
Expand All @@ -51,14 +51,14 @@ def example2(self, arg1=10):
return arg1, type(arg1)


class MixedArguments(object):
class MixedArguments:

@decorators.SetParseFns(float, arg2=str)
def example3(self, arg1, arg2):
return arg1, arg2


class PartialParseFn(object):
class PartialParseFn:

@decorators.SetParseFns(arg1=str)
def example4(self, arg1, arg2):
Expand All @@ -69,7 +69,7 @@ def example5(self, arg1, arg2):
return arg1, arg2


class WithKwargs(object):
class WithKwargs:

@decorators.SetParseFns(mode=str, count=int)
def example6(self, **kwargs):
Expand All @@ -79,7 +79,7 @@ def example6(self, **kwargs):
)


class WithVarArgs(object):
class WithVarArgs:

@decorators.SetParseFn(str)
def example7(self, arg1, arg2=None, *varargs, **kwargs): # pylint: disable=keyword-arg-before-vararg
Expand Down
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
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -767,7 +767,7 @@ def _CreateAvailabilityLine(header, items,
return indented_header + indented_items_text[len(indented_header):] + '\n'


class ActionGroup(object):
class ActionGroup:
"""A group of actions of the same kind."""

def __init__(self, name, plural):
Expand Down
3 changes: 1 addition & 2 deletions fire/helptext_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class HelpTest(testutils.BaseTestCase):

def setUp(self):
super(HelpTest, self).setUp()
super().setUp()
os.environ['ANSI_COLORS_DISABLED'] = '1'

def testHelpTextNoDefaults(self):
Expand Down Expand Up @@ -428,7 +428,6 @@ def testHelpTextMultipleKeywoardArgumentsWithShortArgs(self):
self.assertIn('\n --late', help_screen)



class UsageTest(testutils.BaseTestCase):

def testUsageOutput(self):
Expand Down
6 changes: 3 additions & 3 deletions fire/inspectutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from fire import docstrings


class FullArgSpec(object):
class FullArgSpec:
"""The arguments of a function, as in Python 3's inspect.FullArgSpec."""

def __init__(self, args=None, varargs=None, varkw=None, defaults=None,
Expand Down Expand Up @@ -229,7 +229,7 @@ def GetFileAndLine(component):
try:
unused_code, lineindex = inspect.findsource(component)
lineno = lineindex + 1
except (IOError, IndexError):
except (OSError, IndexError):
lineno = None

return filename, lineno
Expand Down Expand Up @@ -268,7 +268,7 @@ def Info(component):
try:
unused_code, lineindex = inspect.findsource(component)
info['line'] = lineindex + 1
except (TypeError, IOError):
except (TypeError, OSError):
info['line'] = None

if 'docstring' in info:
Expand Down
2 changes: 1 addition & 1 deletion fire/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MainModuleFileTest(testutils.BaseTestCase):
"""Tests to verify correct import behavior for file executables."""

def setUp(self):
super(MainModuleFileTest, self).setUp()
super().setUp()
self.file = tempfile.NamedTemporaryFile(suffix='.py') # pylint: disable=consider-using-with
self.file.write(b'class Foo:\n def double(self, n):\n return 2 * n\n')
self.file.flush()
Expand Down
2 changes: 1 addition & 1 deletion fire/parser_fuzz_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def testDefaultParseValueFuzz(self, value):
result = parser.DefaultParseValue(value)
except TypeError:
# It's OK to get a TypeError if the string has the null character.
if u'\x00' in value:
if '\x00' in value:
return
raise
except MemoryError:
Expand Down
Loading

0 comments on commit f6f99fc

Please sign in to comment.