mirror of
https://github.com/ZwareBear/awx.git
synced 2026-03-19 23:33:37 -05:00
Add new flak8 rules to do some meaningful corrections
This commit is contained in:
@@ -24,7 +24,6 @@ __all__ = [
|
|||||||
'InventoryInventorySourcesUpdatePermission',
|
'InventoryInventorySourcesUpdatePermission',
|
||||||
'UserPermission',
|
'UserPermission',
|
||||||
'IsSystemAdminOrAuditor',
|
'IsSystemAdminOrAuditor',
|
||||||
'InstanceGroupTowerPermission',
|
|
||||||
'WorkflowApprovalPermission',
|
'WorkflowApprovalPermission',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -3096,8 +3096,7 @@ class WorkflowJobNodeChildrenBaseList(SubListAPIView):
|
|||||||
search_fields = ('unified_job_template__name', 'unified_job_template__description')
|
search_fields = ('unified_job_template__name', 'unified_job_template__description')
|
||||||
|
|
||||||
#
|
#
|
||||||
# Limit the set of WorkflowJobeNodes to the related nodes of specified by
|
# Limit the set of WorkflowJobNodes to the related nodes of specified by self.relationship
|
||||||
#'relationship'
|
|
||||||
#
|
#
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
parent = self.get_parent_object()
|
parent = self.get_parent_object()
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from django.utils.timezone import now
|
|||||||
|
|
||||||
logger = logging.getLogger('awx.main.migrations')
|
logger = logging.getLogger('awx.main.migrations')
|
||||||
|
|
||||||
__all__ = ['create_collection_jt', 'create_clearsessions_jt', 'create_cleartokens_jt']
|
__all__ = ['create_clearsessions_jt', 'create_cleartokens_jt']
|
||||||
|
|
||||||
'''
|
'''
|
||||||
These methods are called by migrations to create various system job templates
|
These methods are called by migrations to create various system job templates
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ def migrate_galaxy_settings(apps, schema_editor):
|
|||||||
credential_type=galaxy_type,
|
credential_type=galaxy_type,
|
||||||
inputs={'url': 'https://galaxy.ansible.com/'},
|
inputs={'url': 'https://galaxy.ansible.com/'},
|
||||||
)
|
)
|
||||||
except:
|
except Exception:
|
||||||
# Needed for new migrations, tests
|
# Needed for new migrations, tests
|
||||||
public_galaxy_credential = Credential(
|
public_galaxy_credential = Credential(
|
||||||
created=now(), modified=now(), name='Ansible Galaxy', managed=True, credential_type=galaxy_type, inputs={'url': 'https://galaxy.ansible.com/'}
|
created=now(), modified=now(), name='Ansible Galaxy', managed=True, credential_type=galaxy_type, inputs={'url': 'https://galaxy.ansible.com/'}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class Schedule(PrimordialModel, LaunchTimeConfig):
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Find the DTSTART rule or raise an error, its usually the first rule but that is not strictly enforced
|
# Find the DTSTART rule or raise an error, its usually the first rule but that is not strictly enforced
|
||||||
start_date_rule = re.sub('^.*(DTSTART[^\s]+)\s.*$', r'\1', rrule)
|
start_date_rule = re.sub(r'^.*(DTSTART[^\s]+)\s.*$', r'\1', rrule)
|
||||||
if not start_date_rule:
|
if not start_date_rule:
|
||||||
raise ValueError('A DTSTART field needs to be in the rrule')
|
raise ValueError('A DTSTART field needs to be in the rrule')
|
||||||
|
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ def test_instance_attach_to_instance_group(post, instance_group, node_type_insta
|
|||||||
|
|
||||||
count = ActivityStream.objects.count()
|
count = ActivityStream.objects.count()
|
||||||
|
|
||||||
url = reverse(f'api:instance_group_instance_list', kwargs={'pk': instance_group.pk})
|
url = reverse('api:instance_group_instance_list', kwargs={'pk': instance_group.pk})
|
||||||
post(url, {'associate': True, 'id': instance.id}, admin, expect=204 if node_type != 'control' else 400)
|
post(url, {'associate': True, 'id': instance.id}, admin, expect=204 if node_type != 'control' else 400)
|
||||||
|
|
||||||
new_activity = ActivityStream.objects.all()[count:]
|
new_activity = ActivityStream.objects.all()[count:]
|
||||||
@@ -240,7 +240,7 @@ def test_instance_unattach_from_instance_group(post, instance_group, node_type_i
|
|||||||
|
|
||||||
count = ActivityStream.objects.count()
|
count = ActivityStream.objects.count()
|
||||||
|
|
||||||
url = reverse(f'api:instance_group_instance_list', kwargs={'pk': instance_group.pk})
|
url = reverse('api:instance_group_instance_list', kwargs={'pk': instance_group.pk})
|
||||||
post(url, {'disassociate': True, 'id': instance.id}, admin, expect=204 if node_type != 'control' else 400)
|
post(url, {'disassociate': True, 'id': instance.id}, admin, expect=204 if node_type != 'control' else 400)
|
||||||
|
|
||||||
new_activity = ActivityStream.objects.all()[count:]
|
new_activity = ActivityStream.objects.all()[count:]
|
||||||
@@ -263,7 +263,7 @@ def test_instance_group_attach_to_instance(post, instance_group, node_type_insta
|
|||||||
|
|
||||||
count = ActivityStream.objects.count()
|
count = ActivityStream.objects.count()
|
||||||
|
|
||||||
url = reverse(f'api:instance_instance_groups_list', kwargs={'pk': instance.pk})
|
url = reverse('api:instance_instance_groups_list', kwargs={'pk': instance.pk})
|
||||||
post(url, {'associate': True, 'id': instance_group.id}, admin, expect=204 if node_type != 'control' else 400)
|
post(url, {'associate': True, 'id': instance_group.id}, admin, expect=204 if node_type != 'control' else 400)
|
||||||
|
|
||||||
new_activity = ActivityStream.objects.all()[count:]
|
new_activity = ActivityStream.objects.all()[count:]
|
||||||
@@ -287,7 +287,7 @@ def test_instance_group_unattach_from_instance(post, instance_group, node_type_i
|
|||||||
|
|
||||||
count = ActivityStream.objects.count()
|
count = ActivityStream.objects.count()
|
||||||
|
|
||||||
url = reverse(f'api:instance_instance_groups_list', kwargs={'pk': instance.pk})
|
url = reverse('api:instance_instance_groups_list', kwargs={'pk': instance.pk})
|
||||||
post(url, {'disassociate': True, 'id': instance_group.id}, admin, expect=204 if node_type != 'control' else 400)
|
post(url, {'disassociate': True, 'id': instance_group.id}, admin, expect=204 if node_type != 'control' else 400)
|
||||||
|
|
||||||
new_activity = ActivityStream.objects.all()[count:]
|
new_activity = ActivityStream.objects.all()[count:]
|
||||||
@@ -314,4 +314,4 @@ def test_cannot_remove_controlplane_hybrid_instances(post, controlplane_instance
|
|||||||
|
|
||||||
url = reverse('api:instance_instance_groups_list', kwargs={'pk': instance.pk})
|
url = reverse('api:instance_instance_groups_list', kwargs={'pk': instance.pk})
|
||||||
r = post(url, {'disassociate': True, 'id': controlplane_instance_group.id}, admin_user, expect=400)
|
r = post(url, {'disassociate': True, 'id': controlplane_instance_group.id}, admin_user, expect=400)
|
||||||
assert f'Cannot disassociate hybrid instance' in str(r.data)
|
assert 'Cannot disassociate hybrid instance' in str(r.data)
|
||||||
|
|||||||
@@ -123,19 +123,19 @@ def test_encrypted_survey_answer(post, patch, admin_user, project, inventory, su
|
|||||||
("DTSTART:20030925T104941Z RRULE:FREQ=DAILY;INTERVAL=10;COUNT=500;UNTIL=20040925T104941Z", "RRULE may not contain both COUNT and UNTIL"), # noqa
|
("DTSTART:20030925T104941Z RRULE:FREQ=DAILY;INTERVAL=10;COUNT=500;UNTIL=20040925T104941Z", "RRULE may not contain both COUNT and UNTIL"), # noqa
|
||||||
("DTSTART:20300308T050000Z RRULE:FREQ=DAILY;INTERVAL=1;COUNT=2000", "COUNT > 999 is unsupported"), # noqa
|
("DTSTART:20300308T050000Z RRULE:FREQ=DAILY;INTERVAL=1;COUNT=2000", "COUNT > 999 is unsupported"), # noqa
|
||||||
# Individual rule test with multiple rules
|
# Individual rule test with multiple rules
|
||||||
## Bad Rule: RRULE:NONSENSE
|
# Bad Rule: RRULE:NONSENSE
|
||||||
("DTSTART:20300308T050000Z RRULE:NONSENSE RRULE:INTERVAL=1;FREQ=DAILY EXRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=SU", "INTERVAL required in rrule"),
|
("DTSTART:20300308T050000Z RRULE:NONSENSE RRULE:INTERVAL=1;FREQ=DAILY EXRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=SU", "INTERVAL required in rrule"),
|
||||||
## Bad Rule: RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=5MO
|
# Bad Rule: RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=5MO
|
||||||
(
|
(
|
||||||
"DTSTART:20300308T050000Z RRULE:INTERVAL=1;FREQ=DAILY EXRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=SU RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=5MO",
|
"DTSTART:20300308T050000Z RRULE:INTERVAL=1;FREQ=DAILY EXRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=SU RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=5MO",
|
||||||
"BYDAY with numeric prefix not supported",
|
"BYDAY with numeric prefix not supported",
|
||||||
), # noqa
|
), # noqa
|
||||||
## Bad Rule: RRULE:FREQ=DAILY;INTERVAL=10;COUNT=500;UNTIL=20040925T104941Z
|
# Bad Rule: RRULE:FREQ=DAILY;INTERVAL=10;COUNT=500;UNTIL=20040925T104941Z
|
||||||
(
|
(
|
||||||
"DTSTART:20030925T104941Z RRULE:INTERVAL=1;FREQ=DAILY EXRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=SU RRULE:FREQ=DAILY;INTERVAL=10;COUNT=500;UNTIL=20040925T104941Z",
|
"DTSTART:20030925T104941Z RRULE:INTERVAL=1;FREQ=DAILY EXRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=SU RRULE:FREQ=DAILY;INTERVAL=10;COUNT=500;UNTIL=20040925T104941Z",
|
||||||
"RRULE may not contain both COUNT and UNTIL",
|
"RRULE may not contain both COUNT and UNTIL",
|
||||||
), # noqa
|
), # noqa
|
||||||
## Bad Rule: RRULE:FREQ=DAILY;INTERVAL=1;COUNT=2000
|
# Bad Rule: RRULE:FREQ=DAILY;INTERVAL=1;COUNT=2000
|
||||||
(
|
(
|
||||||
"DTSTART:20300308T050000Z RRULE:INTERVAL=1;FREQ=DAILY EXRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=SU RRULE:FREQ=DAILY;INTERVAL=1;COUNT=2000",
|
"DTSTART:20300308T050000Z RRULE:INTERVAL=1;FREQ=DAILY EXRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=SU RRULE:FREQ=DAILY;INTERVAL=1;COUNT=2000",
|
||||||
"COUNT > 999 is unsupported",
|
"COUNT > 999 is unsupported",
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ __metaclass__ = type
|
|||||||
import gnupg
|
import gnupg
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
from ansible.plugins.action import ActionBase
|
from ansible.plugins.action import ActionBase
|
||||||
from ansible.utils.display import Display
|
from ansible.utils.display import Display
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@ from ansible_sign.checksum import (
|
|||||||
InvalidChecksumLine,
|
InvalidChecksumLine,
|
||||||
)
|
)
|
||||||
from ansible_sign.checksum.differ import DistlibManifestChecksumFileExistenceDiffer
|
from ansible_sign.checksum.differ import DistlibManifestChecksumFileExistenceDiffer
|
||||||
from ansible_sign.signing import *
|
from ansible_sign.signing import GPGVerifier
|
||||||
|
|
||||||
display = Display()
|
display = Display()
|
||||||
|
|
||||||
|
|||||||
@@ -101,5 +101,5 @@ except IOError:
|
|||||||
# The below runs AFTER all of the custom settings are imported.
|
# The below runs AFTER all of the custom settings are imported.
|
||||||
|
|
||||||
DATABASES.setdefault('default', dict()).setdefault('OPTIONS', dict()).setdefault(
|
DATABASES.setdefault('default', dict()).setdefault('OPTIONS', dict()).setdefault(
|
||||||
'application_name', f'{CLUSTER_HOST_ID}-{os.getpid()}-{" ".join(sys.argv)}'[:63]
|
'application_name', f'{CLUSTER_HOST_ID}-{os.getpid()}-{" ".join(sys.argv)}'[:63] # NOQA
|
||||||
) # noqa
|
) # noqa
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ _values_to_change = ['is_superuser_value', 'is_superuser_role', 'is_system_audit
|
|||||||
|
|
||||||
def _get_setting():
|
def _get_setting():
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
cursor.execute(f'SELECT value FROM conf_setting WHERE key= %s', ['SOCIAL_AUTH_SAML_USER_FLAGS_BY_ATTR'])
|
cursor.execute('SELECT value FROM conf_setting WHERE key= %s', ['SOCIAL_AUTH_SAML_USER_FLAGS_BY_ATTR'])
|
||||||
row = cursor.fetchone()
|
row = cursor.fetchone()
|
||||||
if row == None:
|
if row == None:
|
||||||
return {}
|
return {}
|
||||||
@@ -24,7 +24,7 @@ def _get_setting():
|
|||||||
|
|
||||||
def _set_setting(value):
|
def _set_setting(value):
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
cursor.execute(f'UPDATE conf_setting SET value = %s WHERE key = %s', [json.dumps(value), 'SOCIAL_AUTH_SAML_USER_FLAGS_BY_ATTR'])
|
cursor.execute('UPDATE conf_setting SET value = %s WHERE key = %s', [json.dumps(value), 'SOCIAL_AUTH_SAML_USER_FLAGS_BY_ATTR'])
|
||||||
|
|
||||||
|
|
||||||
def forwards(app, schema_editor):
|
def forwards(app, schema_editor):
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ def create_workflow_nodes(module, response, workflow_nodes, workflow_id):
|
|||||||
# Lookup Job Template ID
|
# Lookup Job Template ID
|
||||||
if workflow_node['unified_job_template']['name']:
|
if workflow_node['unified_job_template']['name']:
|
||||||
if workflow_node['unified_job_template']['type'] is None:
|
if workflow_node['unified_job_template']['type'] is None:
|
||||||
module.fail_json(msg='Could not find unified job template type in workflow_nodes {1}'.format(workflow_node))
|
module.fail_json(msg='Could not find unified job template type in workflow_nodes {0}'.format(workflow_node))
|
||||||
search_fields['type'] = workflow_node['unified_job_template']['type']
|
search_fields['type'] = workflow_node['unified_job_template']['type']
|
||||||
if workflow_node['unified_job_template']['type'] == 'inventory_source':
|
if workflow_node['unified_job_template']['type'] == 'inventory_source':
|
||||||
if 'inventory' in workflow_node['unified_job_template']:
|
if 'inventory' in workflow_node['unified_job_template']:
|
||||||
|
|||||||
2
tox.ini
2
tox.ini
@@ -16,5 +16,5 @@ commands =
|
|||||||
yamllint -s .
|
yamllint -s .
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
select = F401,F402,F821,F823,F841,F811
|
select = F401,F402,F821,F823,F841,F811,E265,E266,F541,W605,E722,F822,F523,W291,F405
|
||||||
exclude = awx/ui/node_modules,awx/ui/node_modules,env,awx_collection_build
|
exclude = awx/ui/node_modules,awx/ui/node_modules,env,awx_collection_build
|
||||||
|
|||||||
Reference in New Issue
Block a user