Fix PEP8 issues with latest pycodestyle (#6636)

This commit is contained in:
Aditya Toshniwal 2023-07-31 18:14:39 +05:30 committed by GitHub
parent 2aea5b41ad
commit a1c7265c41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 18 additions and 18 deletions

View File

@ -1,5 +1,5 @@
[pycodestyle]
ignore = E402,W504,W605
ignore = E402,W504,W605,E231,W605
max-line-length = 79
statistics = True
show-source = False

View File

@ -24,7 +24,7 @@ def get_my_ip():
except Exception:
external_ip = '127.0.0.1'
if type(external_ip) == bytes:
if isinstance(external_ip, bytes):
external_ip = external_ip.decode('utf-8')
ip = ipaddress.ip_address(external_ip)

View File

@ -24,7 +24,7 @@ def check_validation_view_content(test):
]
def mock_log_exception(ex):
test.assertTrue(type(ex) == ValidationException)
test.assertTrue(isinstance(ex, ValidationException))
with patch(
__MFA_PACKAGE + ".utils.current_user", return_value=MockCurrentUserId()

View File

@ -160,7 +160,7 @@ def mfa_enabled(execute_if_enabled, execute_if_disabled) -> None:
supported_methods = getattr(config, "MFA_SUPPORTED_METHODS", [])
if is_server_mode is True and enabled is True and \
type(supported_methods) == list:
isinstance(supported_methods, list):
supported_methods, _ = segregate_valid_and_invalid_mfa_methods(
supported_methods
)

View File

@ -914,7 +914,7 @@ class SubscriptionView(PGChildNodeView, SchemaDiffObjectCompare):
drop_sql = kwargs.get('drop_sql', False)
if data:
if 'pub' in data and type(data['pub']) == str:
if 'pub' in data and isinstance(data['pub'], str):
# Convert publication details to list
data['pub'] = data['pub'].split(',,')
sql, name = self.get_sql(data=data, subid=oid)

View File

@ -598,7 +598,7 @@ SELECT EXISTS(
"""
# Format the schedule data. Convert the boolean array
jschedules = data.get('jschedules', {})
if type(jschedules) == dict:
if isinstance(jschedules, dict):
for schedule in jschedules.get('added', []):
format_schedule_data(schedule)
for schedule in jschedules.get('changed', []):
@ -606,7 +606,7 @@ SELECT EXISTS(
has_connection_str = self.manager.db_info['pgAgent']['has_connstr']
jssteps = data.get('jsteps', {})
if type(jssteps) == dict:
if isinstance(jssteps, dict):
for changed_step in jssteps.get('changed', []):
status, res = format_step_data(
data['jobid'], changed_step, has_connection_str,

View File

@ -28,7 +28,7 @@ def get_my_ip():
except Exception:
external_ip = '127.0.0.1'
if type(external_ip) == bytes:
if isinstance(external_ip, bytes):
external_ip = external_ip.decode('utf-8')
ip = ipaddress.ip_address(external_ip)

View File

@ -212,7 +212,7 @@ def init_filemanager():
data = Filemanager.get_trasaction_selection(trans_id)
pref = Preferences.module('file_manager')
file_dialog_view = pref.preference('file_dialog_view').get()
if type(file_dialog_view) == list:
if isinstance(file_dialog_view, list):
file_dialog_view = file_dialog_view[0]
last_selected_format = get_file_type_setting(data['supported_types'])
@ -1157,6 +1157,6 @@ def file_manager(trans_id):
except PermissionError as e:
return unauthorized(str(e))
if type(res) == Response:
if isinstance(res, Response):
return res
return make_json_response(data={'result': res, 'status': True})

View File

@ -663,7 +663,7 @@ def tables(params):
params.get('tid', None))
if not status:
tables = tables.json if type(tables) == Response else tables
tables = tables.json if isinstance(tables, Response) else tables
socketio.emit('tables_failed', tables,
namespace=SOCKETIO_NAMESPACE,
to=request.sid)

View File

@ -446,8 +446,8 @@ def compare_database(params):
params['target_sid'])
if not status:
socketio.emit('compare_database_failed',
error_msg.json if type(
error_msg) == Response else error_msg,
error_msg.json if isinstance(
error_msg, Response) else error_msg,
namespace=SOCKETIO_NAMESPACE, to=request.sid)
return error_msg
@ -585,8 +585,8 @@ def compare_schema(params):
params['target_sid'])
if not status:
socketio.emit('compare_schema_failed',
error_msg.json if type(
error_msg) == Response else error_msg,
error_msg.json if isinstance(
error_msg, Response) else error_msg,
namespace=SOCKETIO_NAMESPACE, to=request.sid)
return error_msg

View File

@ -467,7 +467,7 @@ def validate_user(data):
if 'auth_source' in data and data['auth_source'] != "":
new_data['auth_source'] = data['auth_source']
if 'locked' in data and type(data['locked']) == bool:
if 'locked' in data and isinstance(data['locked'], bool):
new_data['locked'] = data['locked']
if data['locked']:
new_data['login_attempts'] = config.MAX_LOGIN_ATTEMPTS

View File

@ -279,8 +279,8 @@ class Driver(BaseDriver):
if conn:
try:
if type(conn) != psycopg.Connection and \
type(conn) != psycopg.AsyncConnection:
if not isinstance(conn, psycopg.Connection) and \
not isinstance(conn, psycopg.AsyncConnection):
conn = conn.conn
res = psycopg.sql.Literal(value).as_string(conn).strip()
except Exception: