Skip to content

Commit

Permalink
Fix PEP8 issues with latest pycodestyle (pgadmin-org#6636)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityatoshniwal authored and akshay-joshi committed Aug 4, 2023
1 parent 69085c4 commit bf3d3c6
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .pycodestyle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pycodestyle]
ignore = E402,W504,W605
ignore = E402,W504,W605,E231,W605
max-line-length = 79
statistics = True
show-source = False
Expand Down
2 changes: 1 addition & 1 deletion web/pgacloud/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion web/pgadmin/authenticate/mfa/tests/test_mfa_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion web/pgadmin/authenticate/mfa/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ def get_sql_from_diff(self, **kwargs):
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)
Expand Down
4 changes: 2 additions & 2 deletions web/pgadmin/browser/server_groups/servers/pgagent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,15 +598,15 @@ def format_schedule_step_data(self, data):
"""
# 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', []):
format_schedule_data(schedule)

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,
Expand Down
2 changes: 1 addition & 1 deletion web/pgadmin/misc/cloud/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions web/pgadmin/misc/file_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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})
2 changes: 1 addition & 1 deletion web/pgadmin/tools/erd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions web/pgadmin/tools/schema_diff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion web/pgadmin/tools/user_management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions web/pgadmin/utils/driver/psycopg3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ def qtLiteral(value, conn, force_quote=False):

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:
Expand Down

0 comments on commit bf3d3c6

Please sign in to comment.