Skip to content

Commit

Permalink
lint: Up-rev hacking
Browse files Browse the repository at this point in the history
Without up-reving hacking python 3.12 can't be used for pep8/flake8
checks. Also address a few new pyflakes issues that seem reasonable
to enforce:

   E275 missing whitespace after keyword
   H214 Use assertIn/NotIn(A, B) rather than
        assertTrue/False(A in/not in B)
   H211 do not compare types, use assert{Is,IsNot}Instance

Add F811 (redefinition of unused 'function'), as this check makes
client.py fail.

And noqa some longer lines that we're happy to carry.

Change-Id: Ic97698a310ffe7114b668b8c4bc0195f6997bb45
  • Loading branch information
matthewoliver authored and tipabu committed Feb 21, 2024
1 parent b9fb6ca commit 1e0ab24
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions swiftclient/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ def st_stat(parser, args, output_manager, return_parser=False):
items, headers, output_manager
)
else:
raise(stat_result["error"])
raise stat_result["error"]
else:
output_manager.error(
'Usage: %s stat %s\n%s', BASENAME,
Expand All @@ -768,7 +768,7 @@ def st_stat(parser, args, output_manager, return_parser=False):
[--sync-key <sync-key>] [--meta <name:value>]
[--header <header>]
[<container> [<object>]]
'''
''' # noqa

st_post_help = '''
Updates meta information for the account, container, or object.
Expand Down Expand Up @@ -864,7 +864,7 @@ def st_post(parser, args, output_manager, return_parser=False):
else:
result = swift.post(container=container)
if not result["success"]:
raise(result["error"])
raise result["error"]

except SwiftError as e:
output_manager.error(e.value)
Expand Down Expand Up @@ -1520,7 +1520,7 @@ def st_tempurl(parser, args, thread_manager, return_parser=False):
Optional positional arguments:
<command> Swift client command to filter the flags by.
'''.strip('\n')
'''.strip('\n') # noqa


st_bash_completion_options = '''[command]
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
hacking>=3.2.0,<3.3.0 # Apache-2.0
hacking>=3.2.0,<6.2.0 # Apache-2.0

coverage!=4.4,>=4.0 # Apache-2.0
keystoneauth1>=3.4.0 # Apache-2.0
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,7 @@ def test_upload_stream(self, mock_conn):
options)
responses = [x for x in resp_iter]
for resp in responses:
self.assertFalse('error' in resp)
self.assertNotIn('error', resp)
self.assertTrue(resp['success'])
self.assertEqual(5, len(responses))
container_resp, segment_container_resp = responses[0:2]
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ def test_download(self, connection, makedirs):
@mock.patch('swiftclient.service.Connection')
def test_download_shuffle(self, connection, mock_shuffle):
# Test that the container and object lists are shuffled
mock_shuffle.side_effect = lambda l: l
mock_shuffle.side_effect = lambda to_shuffle: to_shuffle
connection.return_value.get_object.return_value = [
{'content-type': 'text/plain',
'etag': EMPTY_ETAG},
Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_swiftclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,7 @@ def test_instance_kwargs(self):
'authurl': 'http://www.test.com',
'tenant_name': 'atenant'}
conn = c.Connection(**args)
self.assertEqual(type(conn), c.Connection)
self.assertIsInstance(conn, c.Connection)

def test_instance_kwargs_token(self):
args = {'preauthtoken': 'atoken123',
Expand Down Expand Up @@ -3056,7 +3056,7 @@ def test_close_ok(self):
conn = c.Connection(url, 'asdf', 'asdf')
self.assertIsNone(conn.http_conn)
conn.http_conn = c.http_connection(url)
self.assertEqual(type(conn.http_conn), tuple)
self.assertIsInstance(conn.http_conn, tuple)
self.assertEqual(len(conn.http_conn), 2)
http_conn_obj = conn.http_conn[1]
self.assertIsInstance(http_conn_obj, c.HTTPConnection)
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ commands=
# H404: multi line docstring should start without a leading new line
# H405: multi line docstring summary not separated with an empty line
# W504: line break after binary operator
ignore = H101,H301,H306,H401,H403,H404,H405,W504
# F811: Redefinition of unused name from line n
ignore = H101,H301,H306,H401,H403,H404,H405,W504,F811
# H106: Don’t put vim configuration in source files
# H203: Use assertIs(Not)None to check for None
enable-extensions=H106,H203
Expand Down

0 comments on commit 1e0ab24

Please sign in to comment.