Skip to content

Commit 1812252

Browse files
committed
linting with Ruff
1 parent 77d9e39 commit 1812252

16 files changed

+40
-35
lines changed

fire/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def import_from_file_path(path):
6464
raise OSError('Unable to load module from specified path.')
6565

6666
module = util.module_from_spec(spec) # pylint: disable=no-member
67-
spec.loader.exec_module(module) # pytype: disable=attribute-error
67+
spec.loader.exec_module(module)
6868

6969
return module, module_name
7070

fire/console/console_attr_os.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def GetTermSize():
4747
xy = get_terminal_size()
4848
if xy:
4949
break
50-
except: # pylint: disable=bare-except
50+
except: # noqa: E722
5151
pass
5252
return xy or (80, 24)
5353

@@ -75,7 +75,7 @@ def _GetXY(fd):
7575
# binary shorts to a (rows, columns) int tuple.
7676
rc = struct.unpack(b'hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, 'junk'))
7777
return (rc[1], rc[0]) if rc else None
78-
except: # pylint: disable=bare-except
78+
except: # noqa: E722
7979
return None
8080

8181
xy = _GetXY(0) or _GetXY(1) or _GetXY(2)
@@ -84,7 +84,7 @@ def _GetXY(fd):
8484
try:
8585
fd = os.open(os.ctermid(), os.O_RDONLY)
8686
xy = _GetXY(fd)
87-
except: # pylint: disable=bare-except
87+
except: # noqa: E722
8888
xy = None
8989
finally:
9090
if fd is not None:
@@ -153,7 +153,7 @@ def GetRawKeyFunction():
153153
_GetRawKeyFunctionWindows):
154154
try:
155155
return get_raw_key_function()
156-
except: # pylint: disable=bare-except
156+
except: # noqa: E722
157157
pass
158158
return lambda: None
159159

@@ -212,7 +212,7 @@ def _GetKeyChar():
212212
c = prev_c
213213
break
214214
return ansi_to_key.get(c, '')
215-
except: # pylint:disable=bare-except
215+
except: # noqa: E722
216216
c = None
217217
finally:
218218
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)

fire/console/encoding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ def Decode(data, encoding=None):
9191

9292
# Try the filesystem encoding.
9393
try:
94-
return string.decode(sys.getfilesystemencoding()) # pytype: disable=attribute-error
94+
return string.decode(sys.getfilesystemencoding()) # pytype: disable=attribute-error, # noqa: E501
9595
except UnicodeError:
9696
# string is not encoded for filesystem paths.
9797
pass
9898

9999
# Try the system default encoding.
100100
try:
101-
return string.decode(sys.getdefaultencoding()) # pytype: disable=attribute-error
101+
return string.decode(sys.getdefaultencoding()) # pytype: disable=attribute-error, # noqa: E501
102102
except UnicodeError:
103103
# string is not encoded using the default encoding.
104104
pass

fire/console/text.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,3 @@ class TextTypes(_TextTypes):
100100
OUTPUT = 7
101101
PT_SUCCESS = 8
102102
PT_FAILURE = 9
103-

fire/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def GetMetadata(fn) -> Dict[str, Any]:
100100
return metadata
101101
else:
102102
return default
103-
except: # pylint: disable=bare-except
103+
except: # noqa: E722
104104
return default
105105

106106

fire/docstrings_test.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def test_one_line_simple_whitespace(self):
4646

4747
def test_one_line_too_long(self):
4848
# pylint: disable=line-too-long
49-
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.
49+
docstring = """A one line docstring that is both a little too verbose
50+
and a little too long so it keeps going well beyond a reasonable length
51+
for a one-liner.
5052
"""
5153
# pylint: enable=line-too-long
5254
docstring_info = docstrings.parse(docstring)
@@ -59,8 +61,8 @@ def test_one_line_too_long(self):
5961

6062
def test_one_line_runs_over(self):
6163
# pylint: disable=line-too-long
62-
docstring = """A one line docstring that is both a little too verbose and a little too long
63-
so it runs onto a second line.
64+
docstring = """A one line docstring that is both a little too verbose
65+
and a little too long so it runs onto a second line.
6466
"""
6567
# pylint: enable=line-too-long
6668
docstring_info = docstrings.parse(docstring)
@@ -72,8 +74,8 @@ def test_one_line_runs_over(self):
7274

7375
def test_one_line_runs_over_whitespace(self):
7476
docstring = """
75-
A one line docstring that is both a little too verbose and a little too long
76-
so it runs onto a second line.
77+
A one line docstring that is both a little too verbose
78+
and a little too long so it runs onto a second line.
7779
"""
7880
docstring_info = docstrings.parse(docstring)
7981
expected_docstring_info = DocstringInfo(

fire/fire_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,10 @@ def testFireObjectWithTupleAsObject(self):
323323
def testFireNoComponent(self):
324324
self.assertEqual(fire.Fire(command=['tc', 'WithDefaults', 'double', '10']),
325325
20)
326-
last_char = lambda text: text[-1] # pylint: disable=unused-variable
326+
# last_char = lambda text: text[-1]
327327
self.assertEqual(fire.Fire(command=['last_char', '"Hello"']), 'o')
328328
self.assertEqual(fire.Fire(command=['last-char', '"World"']), 'd')
329-
rset = lambda count=0: set(range(count)) # pylint: disable=unused-variable
329+
# rset = lambda count=0: set(range(count))
330330
self.assertEqual(fire.Fire(command=['rset', '5']), {0, 1, 2, 3, 4})
331331

332332
def testFireUnderscores(self):

fire/formatting.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
"""Formatting utilities for use in creating help text."""
1616

17-
from fire import formatting_windows # pylint: disable=unused-import
1817
import termcolor
1918

2019

fire/formatting_windows.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import sys
2222

2323
try:
24-
import colorama # pylint: disable=g-import-not-at-top, # pytype: disable=import-error
24+
import colorama # pytype: disable=import-error
2525
HAS_COLORAMA = True
2626
except ImportError:
2727
HAS_COLORAMA = False
@@ -40,7 +40,8 @@ def initialize_or_disable():
4040
wrap = False
4141
kernel32 = ctypes.windll.kernel32 # pytype: disable=module-attr
4242
enable_virtual_terminal_processing = 0x04
43-
out_handle = kernel32.GetStdHandle(subprocess.STD_OUTPUT_HANDLE) # pylint: disable=line-too-long, # pytype: disable=module-attr
43+
out_handle = kernel32.GetStdHandle( # pytype: disable=module-attr
44+
subprocess.STD_OUTPUT_HANDLE)
4445
# GetConsoleMode fails if the terminal isn't native.
4546
mode = ctypes.wintypes.DWORD()
4647
if kernel32.GetConsoleMode(out_handle, ctypes.byref(mode)) == 0:

fire/inspectutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,5 +344,5 @@ def GetClassAttrsDict(component):
344344
def IsCoroutineFunction(fn):
345345
try:
346346
return asyncio.iscoroutinefunction(fn)
347-
except: # pylint: disable=bare-except
347+
except: # noqa: E722
348348
return False

0 commit comments

Comments
 (0)