From 264c93f2ac05672b9155bc68dbf6dda6e96cca2f Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 5 Oct 2025 19:24:25 +0900 Subject: [PATCH] Run pyupgrade to clean up Python 2 syntaxes Update all .py source files by $ pyupgrade --py3-only $(git ls-files | grep ".py$") to modernize the code according to Python 3 syntaxes. pep8 errors are fixed by $ autopep8 --select=E127,E128,E501 --max-line-length 79 -r \ --in-place heat_dashboard and a few manual adjustments. Change-Id: Ib30712e1c77a203a0b14696373fe3b517652ef77 Signed-off-by: Takashi Kajinami --- .pre-commit-config.yaml | 9 +- doc/source/conf.py | 1 - .../content/resource_types/tables.py | 2 +- heat_dashboard/content/stacks/forms.py | 20 ++-- heat_dashboard/content/stacks/mappings.py | 2 +- heat_dashboard/content/stacks/tables.py | 102 +++++++++--------- heat_dashboard/content/stacks/tabs.py | 4 +- heat_dashboard/content/stacks/views.py | 23 ++-- .../content/template_generator/api.py | 2 +- .../content/template_versions/tables.py | 4 +- heat_dashboard/test/helpers.py | 37 +++---- .../orchestration/resourcetypespage.py | 2 +- .../pages/project/orchestration/stackspage.py | 2 +- .../orchestration/templategeneratorpage.py | 2 +- .../orchestration/templateversionspage.py | 2 +- heat_dashboard/test/test_data/glance_data.py | 2 +- heat_dashboard/test/test_data/heat_data.py | 14 +-- heat_dashboard/test/test_data/neutron_data.py | 2 +- heat_dashboard/test/test_data/nova_data.py | 2 +- heat_dashboard/test/test_data/utils.py | 4 +- .../test/tests/content/test_stacks.py | 28 ++--- releasenotes/source/conf.py | 1 - 22 files changed, 135 insertions(+), 132 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 573280b1..20bdcf48 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: trailing-whitespace # Replaces or checks mixed line ending @@ -8,7 +8,7 @@ repos: args: ['--fix', 'lf'] exclude: '.*\.(svg)$' # Forbid files which have a UTF-8 byte-order marker - - id: check-byte-order-marker + - id: fix-byte-order-marker # Checks that non-binary executables have a proper shebang - id: check-executables-have-shebangs # Check for files that contain merge conflict strings. @@ -25,3 +25,8 @@ repos: additional_dependencies: - flake8-import-order>0.18.0,<0.19.0 - horizon + - repo: https://github.com/asottile/pyupgrade + rev: v3.20.0 + hooks: + - id: pyupgrade + args: [--py3-only] diff --git a/doc/source/conf.py b/doc/source/conf.py index 2c996585..f8d5a825 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/heat_dashboard/content/resource_types/tables.py b/heat_dashboard/content/resource_types/tables.py index 39c4efd0..dfb51435 100644 --- a/heat_dashboard/content/resource_types/tables.py +++ b/heat_dashboard/content/resource_types/tables.py @@ -29,7 +29,7 @@ class ResourceTypesTable(tables.DataTable): def get_object_id(self, resource): return resource.resource_type - class Meta(object): + class Meta: name = "resource_types" verbose_name = _("Resource Types") table_actions = (ResourceTypesFilterAction,) diff --git a/heat_dashboard/content/stacks/forms.py b/heat_dashboard/content/stacks/forms.py index 810832d1..cbfe145d 100644 --- a/heat_dashboard/content/stacks/forms.py +++ b/heat_dashboard/content/stacks/forms.py @@ -56,7 +56,7 @@ def image_field_data(request, include_empty_option=False): images.sort(key=lambda c: c.name) images_list = [] for image in images: - image_label = u"{} ({})".format(image.name, filesizeformat(image.size)) + image_label = "{} ({})".format(image.name, filesizeformat(image.size)) images_list.append((image.id, image_label)) if not images: @@ -87,7 +87,7 @@ def create_upload_form_attributes(prefix, input_type, name): class TemplateForm(forms.SelfHandlingForm): - class Meta(object): + class Meta: name = _('Select Template') help_text = _('Select a template to launch a stack.') @@ -167,10 +167,10 @@ class TemplateForm(forms.SelfHandlingForm): def __init__(self, *args, **kwargs): self.next_view = kwargs.pop('next_view') - super(TemplateForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def clean(self): - cleaned = super(TemplateForm, self).clean() + cleaned = super().clean() files = self.request.FILES self.clean_uploaded_files('template', _('template'), cleaned, files) @@ -272,7 +272,7 @@ class TemplateForm(forms.SelfHandlingForm): class ChangeTemplateForm(TemplateForm): - class Meta(object): + class Meta: name = _('Edit Template') help_text = _('Select a new template to re-launch a stack.') stack_id = forms.CharField(label=_('Stack ID'), @@ -283,7 +283,7 @@ class ChangeTemplateForm(TemplateForm): class PreviewTemplateForm(TemplateForm): - class Meta(object): + class Meta: name = _('Preview Template') help_text = _('Select a new template to preview a stack.') @@ -292,7 +292,7 @@ class CreateStackForm(forms.SelfHandlingForm): param_prefix = '__param_' - class Meta(object): + class Meta: name = _('Create Stack') environment_data = forms.CharField( @@ -325,7 +325,7 @@ class CreateStackForm(forms.SelfHandlingForm): # special case: load template data from API, not passed in params if kwargs.get('validate_me'): parameters = kwargs.pop('validate_me') - super(CreateStackForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) if self._stack_password_enabled(): self.fields['password'] = forms.CharField( @@ -448,7 +448,7 @@ class CreateStackForm(forms.SelfHandlingForm): class EditStackForm(CreateStackForm): - class Meta(object): + class Meta: name = _('Update Stack Parameters') stack_id = forms.CharField( @@ -493,7 +493,7 @@ class EditStackForm(CreateStackForm): class PreviewStackForm(CreateStackForm): - class Meta(object): + class Meta: name = _('Preview Stack Parameters') def __init__(self, *args, **kwargs): diff --git a/heat_dashboard/content/stacks/mappings.py b/heat_dashboard/content/stacks/mappings.py index 519e0c14..ad1770cf 100644 --- a/heat_dashboard/content/stacks/mappings.py +++ b/heat_dashboard/content/stacks/mappings.py @@ -136,7 +136,7 @@ def stack_output(output): parts = urlparse.urlsplit(output) if parts.netloc and parts.scheme in ('http', 'https'): url = html.escape(output) - safe_link = '%s' % (url, url) + safe_link = '{}'.format(url, url) return safestring.mark_safe(safe_link) if isinstance(output, dict) or isinstance(output, list): output = json.dumps(output, indent=2) diff --git a/heat_dashboard/content/stacks/tables.py b/heat_dashboard/content/stacks/tables.py index 7dd4c7d7..658aa3a8 100644 --- a/heat_dashboard/content/stacks/tables.py +++ b/heat_dashboard/content/stacks/tables.py @@ -56,16 +56,16 @@ class CheckStack(tables.BatchAction): @staticmethod def action_present(count): return ngettext_lazy( - u"Check Stack", - u"Check Stacks", + "Check Stack", + "Check Stacks", count ) @staticmethod def action_past(count): return ngettext_lazy( - u"Checked Stack", - u"Checked Stacks", + "Checked Stack", + "Checked Stacks", count ) @@ -82,16 +82,16 @@ class SuspendStack(tables.BatchAction): @staticmethod def action_present(count): return ngettext_lazy( - u"Suspend Stack", - u"Suspend Stacks", + "Suspend Stack", + "Suspend Stacks", count ) @staticmethod def action_past(count): return ngettext_lazy( - u"Suspended Stack", - u"Suspended Stacks", + "Suspended Stack", + "Suspended Stacks", count ) @@ -109,16 +109,16 @@ class ResumeStack(tables.BatchAction): @staticmethod def action_present(count): return ngettext_lazy( - u"Resume Stack", - u"Resume Stacks", + "Resume Stack", + "Resume Stacks", count ) @staticmethod def action_past(count): return ngettext_lazy( - u"Resumed Stack", - u"Resumed Stacks", + "Resumed Stack", + "Resumed Stacks", count ) @@ -142,16 +142,16 @@ class DeleteStack(tables.DeleteAction): @staticmethod def action_present(count): return ngettext_lazy( - u"Delete Stack", - u"Delete Stacks", + "Delete Stack", + "Delete Stacks", count ) @staticmethod def action_past(count): return ngettext_lazy( - u"Deleted Stack", - u"Deleted Stacks", + "Deleted Stack", + "Deleted Stacks", count ) @@ -201,65 +201,65 @@ class StacksTable(tables.DataTable): ) STACK_STATUS_DISPLAY_CHOICES = ( ("init_in_progress", pgettext_lazy("current status of stack", - u"Init In Progress")), + "Init In Progress")), ("init_complete", pgettext_lazy("current status of stack", - u"Init Complete")), + "Init Complete")), ("init_failed", pgettext_lazy("current status of stack", - u"Init Failed")), + "Init Failed")), ("create_in_progress", pgettext_lazy("current status of stack", - u"Create In Progress")), + "Create In Progress")), ("create_complete", pgettext_lazy("current status of stack", - u"Create Complete")), + "Create Complete")), ("create_failed", pgettext_lazy("current status of stack", - u"Create Failed")), + "Create Failed")), ("delete_in_progress", pgettext_lazy("current status of stack", - u"Delete In Progress")), + "Delete In Progress")), ("delete_complete", pgettext_lazy("current status of stack", - u"Delete Complete")), + "Delete Complete")), ("delete_failed", pgettext_lazy("current status of stack", - u"Delete Failed")), + "Delete Failed")), ("update_in_progress", pgettext_lazy("current status of stack", - u"Update In Progress")), + "Update In Progress")), ("update_complete", pgettext_lazy("current status of stack", - u"Update Complete")), + "Update Complete")), ("update_failed", pgettext_lazy("current status of stack", - u"Update Failed")), + "Update Failed")), ("rollback_in_progress", pgettext_lazy("current status of stack", - u"Rollback In Progress")), + "Rollback In Progress")), ("rollback_complete", pgettext_lazy("current status of stack", - u"Rollback Complete")), + "Rollback Complete")), ("rollback_failed", pgettext_lazy("current status of stack", - u"Rollback Failed")), + "Rollback Failed")), ("suspend_in_progress", pgettext_lazy("current status of stack", - u"Suspend In Progress")), + "Suspend In Progress")), ("suspend_complete", pgettext_lazy("current status of stack", - u"Suspend Complete")), + "Suspend Complete")), ("suspend_failed", pgettext_lazy("current status of stack", - u"Suspend Failed")), + "Suspend Failed")), ("resume_in_progress", pgettext_lazy("current status of stack", - u"Resume In Progress")), + "Resume In Progress")), ("resume_complete", pgettext_lazy("current status of stack", - u"Resume Complete")), + "Resume Complete")), ("resume_failed", pgettext_lazy("current status of stack", - u"Resume Failed")), + "Resume Failed")), ("adopt_in_progress", pgettext_lazy("current status of stack", - u"Adopt In Progress")), + "Adopt In Progress")), ("adopt_complete", pgettext_lazy("current status of stack", - u"Adopt Complete")), + "Adopt Complete")), ("adopt_failed", pgettext_lazy("current status of stack", - u"Adopt Failed")), + "Adopt Failed")), ("snapshot_in_progress", pgettext_lazy("current status of stack", - u"Snapshot In Progress")), + "Snapshot In Progress")), ("snapshot_complete", pgettext_lazy("current status of stack", - u"Snapshot Complete")), + "Snapshot Complete")), ("snapshot_failed", pgettext_lazy("current status of stack", - u"Snapshot Failed")), + "Snapshot Failed")), ("check_in_progress", pgettext_lazy("current status of stack", - u"Check In Progress")), + "Check In Progress")), ("check_complete", pgettext_lazy("current status of stack", - u"Check Complete")), + "Check Complete")), ("check_failed", pgettext_lazy("current status of stack", - u"Check Failed")), + "Check Failed")), ) name = tables.Column("stack_name", verbose_name=_("Stack Name"), @@ -285,7 +285,7 @@ class StacksTable(tables.DataTable): def get_object_display(self, stack): return stack.stack_name - class Meta(object): + class Meta: name = "stacks" verbose_name = _("Stacks") pagination_param = 'stack_marker' @@ -330,7 +330,7 @@ class EventsTable(tables.DataTable): statusreason = tables.Column("resource_status_reason", verbose_name=_("Status Reason"),) - class Meta(object): + class Meta: name = "events" verbose_name = _("Stack Events") pagination_param = 'event_marker' @@ -342,7 +342,7 @@ class ResourcesUpdateRow(tables.Row): def get_data(self, request, resource_name): try: stack = self.table.stack - stack_identifier = '%s/%s' % (stack.stack_name, stack.id) + stack_identifier = '{}/{}'.format(stack.stack_name, stack.id) # return api.heat.resource_get( # request, stack_identifier, resource_name) return api.heat.resource_get(request, @@ -393,14 +393,14 @@ class ResourcesTable(tables.DataTable): def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs): - super(ResourcesTable, self).__init__( + super().__init__( request, data, needs_form_wrapper, **kwargs) self.stack = kwargs['stack'] def get_object_id(self, datum): return datum.resource_name - class Meta(object): + class Meta: name = "resources" verbose_name = _("Stack Resources") status_columns = ["status_hidden", ] diff --git a/heat_dashboard/content/stacks/tabs.py b/heat_dashboard/content/stacks/tabs.py index 71647b2b..0590c066 100644 --- a/heat_dashboard/content/stacks/tabs.py +++ b/heat_dashboard/content/stacks/tabs.py @@ -99,7 +99,7 @@ class StackEventsTab(tabs.TableTab): def get_events_data(self): stack = self.tab_group.kwargs['stack'] - stack_identifier = '%s/%s' % (stack.stack_name, stack.id) + stack_identifier = '{}/{}'.format(stack.stack_name, stack.id) prev_marker = self.request.GET.get( project_tables.EventsTable._meta.prev_pagination_param) if prev_marker is not None: @@ -156,7 +156,7 @@ class StackResourcesTab(tabs.Tab): def get_context_data(self, request): stack = self.tab_group.kwargs['stack'] try: - stack_identifier = '%s/%s' % (stack.stack_name, stack.id) + stack_identifier = '{}/{}'.format(stack.stack_name, stack.id) resources = api.heat.resources_list(self.request, stack_identifier) LOG.debug('got resources %s', resources) # The stack id is needed to generate the resource URL. diff --git a/heat_dashboard/content/stacks/views.py b/heat_dashboard/content/stacks/views.py index ad0b33e4..06df9f9b 100644 --- a/heat_dashboard/content/stacks/views.py +++ b/heat_dashboard/content/stacks/views.py @@ -42,7 +42,7 @@ class IndexView(tables.DataTableView): template_name = 'project/stacks/index.html' def __init__(self, *args, **kwargs): - super(IndexView, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self._more = None def has_prev_data(self, table): @@ -105,7 +105,7 @@ class SelectTemplateView(forms.ModalFormView): return initial def get_form_kwargs(self): - kwargs = super(SelectTemplateView, self).get_form_kwargs() + kwargs = super().get_form_kwargs() kwargs['next_view'] = CreateStackView return kwargs @@ -121,7 +121,7 @@ class ChangeTemplateView(forms.ModalFormView): page_title = _("Change Template") def get_context_data(self, **kwargs): - context = super(ChangeTemplateView, self).get_context_data(**kwargs) + context = super().get_context_data(**kwargs) args = (self.get_object().id,) context['submit_url'] = reverse(self.submit_url, args=args) return context @@ -144,7 +144,7 @@ class ChangeTemplateView(forms.ModalFormView): } def get_form_kwargs(self): - kwargs = super(ChangeTemplateView, self).get_form_kwargs() + kwargs = super().get_form_kwargs() kwargs['next_view'] = EditStackView return kwargs @@ -159,7 +159,7 @@ class PreviewTemplateView(forms.ModalFormView): page_title = _("Preview Template") def get_form_kwargs(self): - kwargs = super(PreviewTemplateView, self).get_form_kwargs() + kwargs = super().get_form_kwargs() kwargs['next_view'] = PreviewStackView return kwargs @@ -188,7 +188,7 @@ class CreateStackView(forms.ModalFormView): return initial def get_form_kwargs(self): - kwargs = super(CreateStackView, self).get_form_kwargs() + kwargs = super().get_form_kwargs() if 'parameters' in self.kwargs: kwargs['parameters'] = self.kwargs['parameters'] else: @@ -208,7 +208,7 @@ class EditStackView(CreateStackView): page_title = _("Update Stack") def get_initial(self): - initial = super(EditStackView, self).get_initial() + initial = super().get_initial() initial['stack'] = self.get_object()['stack'] if initial['stack']: @@ -218,7 +218,7 @@ class EditStackView(CreateStackView): return initial def get_context_data(self, **kwargs): - context = super(EditStackView, self).get_context_data(**kwargs) + context = super().get_context_data(**kwargs) args = (self.get_object()['stack'].id,) context['submit_url'] = reverse(self.submit_url, args=args) return context @@ -258,8 +258,7 @@ class PreviewStackDetailsView(forms.ModalFormMixin, views.HorizonTemplateView): page_title = _("Preview Stack Details") def get_context_data(self, **kwargs): - context = super( - PreviewStackDetailsView, self).get_context_data(**kwargs) + context = super().get_context_data(**kwargs) context['stack_preview'] = self.kwargs['stack_preview'].to_dict() return context @@ -270,7 +269,7 @@ class DetailView(tabs.TabView): page_title = "{{ stack.stack_name|default:stack.id }}" def get_context_data(self, **kwargs): - context = super(DetailView, self).get_context_data(**kwargs) + context = super().get_context_data(**kwargs) stack = self.get_data(self.request, **kwargs) table = project_tables.StacksTable(self.request) context["stack"] = stack @@ -319,7 +318,7 @@ class ResourceView(tabs.TabView): "default:resource.logical_resource_id }}" def get_context_data(self, **kwargs): - context = super(ResourceView, self).get_context_data(**kwargs) + context = super().get_context_data(**kwargs) context["resource"] = self.get_data(self.request, **kwargs) context["metadata"] = self.get_metadata(self.request, **kwargs) return context diff --git a/heat_dashboard/content/template_generator/api.py b/heat_dashboard/content/template_generator/api.py index 33698bd2..a8f07f7f 100644 --- a/heat_dashboard/content/template_generator/api.py +++ b/heat_dashboard/content/template_generator/api.py @@ -165,7 +165,7 @@ def get_template_versions(request): if version.type == 'hot'] -class APIThread(object): +class APIThread: thread_pool = pool.ThreadPool(processes=API_PARALLEL) async_results = {} diff --git a/heat_dashboard/content/template_versions/tables.py b/heat_dashboard/content/template_versions/tables.py index cc41b4d7..ad6702c5 100644 --- a/heat_dashboard/content/template_versions/tables.py +++ b/heat_dashboard/content/template_versions/tables.py @@ -30,7 +30,7 @@ class TemplateVersionsTable(tables.DataTable): def get_object_id(self, template_versions): return template_versions.version - class Meta(object): + class Meta: name = "template_versions" table_actions = (tables.FilterAction,) verbose_name = _("Template Versions") @@ -45,7 +45,7 @@ class TemplateFunctionsTable(tables.DataTable): def get_object_id(self, template_functions): return template_functions.functions - class Meta(object): + class Meta: name = "template_functions" verbose_name = _("Template Functions") table_actions = (tables.FilterAction,) diff --git a/heat_dashboard/test/helpers.py b/heat_dashboard/test/helpers.py index 9f025750..180a2e2e 100644 --- a/heat_dashboard/test/helpers.py +++ b/heat_dashboard/test/helpers.py @@ -73,14 +73,14 @@ def _apply_panel_mocks(patchers=None): class RequestFactoryWithMessages(RequestFactory): def get(self, *args, **kwargs): - req = super(RequestFactoryWithMessages, self).get(*args, **kwargs) + req = super().get(*args, **kwargs) req.user = utils.get_user(req) req.session = [] req._messages = default_storage(req) return req def post(self, *args, **kwargs): - req = super(RequestFactoryWithMessages, self).post(*args, **kwargs) + req = super().post(*args, **kwargs) req.user = utils.get_user(req) req.session = [] req._messages = default_storage(req) @@ -128,10 +128,10 @@ class TestCase(horizon_helpers.TestCase): self.patchers = _apply_panel_mocks() - super(TestCase, self).setUp() + super().setUp() def _setup_test_data(self): - super(TestCase, self)._setup_test_data() + super()._setup_test_data() test_utils.load_test_data(self) self.context = { 'authorized_tenants': self.tenants.list(), @@ -159,7 +159,7 @@ class TestCase(horizon_helpers.TestCase): self.setActiveUser(**base_kwargs) def _setup_request(self): - super(TestCase, self)._setup_request() + super()._setup_request() self.request.session['token'] = self.token.id def tearDown(self): @@ -167,7 +167,7 @@ class TestCase(horizon_helpers.TestCase): context_processors.openstack = self._real_context_processor utils.get_user = self._real_get_user mock.patch.stopall() - super(TestCase, self).tearDown() + super().tearDown() # cause a test failure if an unmocked API call was attempted if self.missing_mocks: @@ -238,9 +238,10 @@ class TestCase(horizon_helpers.TestCase): "%d errors were found on the form, %d expected" % \ (len(errors), count) if message and message not in str(errors): - self.fail("Expected message not found, instead found: %s" - % ["%s: %s" % (key, [e for e in field_errors]) for - (key, field_errors) in errors.items()]) + self.fail( + "Expected message not found, instead found: %s" + % ["{}: {}".format(key, [e for e in field_errors]) for + (key, field_errors) in errors.items()]) else: assert len(errors) > 0, "No errors were found on the form" @@ -251,9 +252,9 @@ class TestCase(horizon_helpers.TestCase): """ if response.status_code == expected_code: return - self.fail('status code %r != %r: %s' % (response.status_code, - expected_code, - response.content)) + self.fail('status code {!r} != {!r}: {}'.format(response.status_code, + expected_code, + response.content)) def assertItemsCollectionEqual(self, response, items_list): self.assertEqual(response.json, {"items": items_list}) @@ -318,7 +319,7 @@ class BaseAdminViewTests(TestCase): def setActiveUser(self, *args, **kwargs): if "roles" not in kwargs: kwargs['roles'] = [self.roles.admin._info] - super(BaseAdminViewTests, self).setActiveUser(*args, **kwargs) + super().setActiveUser(*args, **kwargs) def setSessionValues(self, **kwargs): settings.SESSION_ENGINE = 'django.contrib.sessions.backends.file' @@ -340,7 +341,7 @@ class APITestCase(TestCase): """ def setUp(self): - super(APITestCase, self).setUp() + super().setUp() utils.patch_middleware_get_user() def fake_keystoneclient(request, admin=False): @@ -361,7 +362,7 @@ class APITestCase(TestCase): self.stub_heatclient()) def tearDown(self): - super(APITestCase, self).tearDown() + super().tearDown() project_api.keystone.keystoneclient = self._original_keystoneclient api.heat.heatclient = self._original_heatclient @@ -398,12 +399,12 @@ class RestAPITestCase(TestCase): # Need this to test both Glance API V1 and V2 versions -class ResetImageAPIVersionMixin(object): +class ResetImageAPIVersionMixin: def setUp(self): - super(ResetImageAPIVersionMixin, self).setUp() + super().setUp() project_api.glance.VERSIONS.clear_active_cache() def tearDown(self): project_api.glance.VERSIONS.clear_active_cache() - super(ResetImageAPIVersionMixin, self).tearDown() + super().tearDown() diff --git a/heat_dashboard/test/integration/pages/project/orchestration/resourcetypespage.py b/heat_dashboard/test/integration/pages/project/orchestration/resourcetypespage.py index 1c7ac9c9..e31d3ec0 100644 --- a/heat_dashboard/test/integration/pages/project/orchestration/resourcetypespage.py +++ b/heat_dashboard/test/integration/pages/project/orchestration/resourcetypespage.py @@ -17,5 +17,5 @@ from openstack_dashboard.test.integration_tests.pages import basepage class ResourcetypesPage(basepage.BaseNavigationPage): def __init__(self, driver, conf): - super(ResourcetypesPage, self).__init__(driver, conf) + super().__init__(driver, conf) self._page_title = "Resource Types" diff --git a/heat_dashboard/test/integration/pages/project/orchestration/stackspage.py b/heat_dashboard/test/integration/pages/project/orchestration/stackspage.py index e9075949..e893bac2 100644 --- a/heat_dashboard/test/integration/pages/project/orchestration/stackspage.py +++ b/heat_dashboard/test/integration/pages/project/orchestration/stackspage.py @@ -17,5 +17,5 @@ from openstack_dashboard.test.integration_tests.pages import basepage class StacksPage(basepage.BaseNavigationPage): def __init__(self, driver, conf): - super(StacksPage, self).__init__(driver, conf) + super().__init__(driver, conf) self._page_title = "Stacks" diff --git a/heat_dashboard/test/integration/pages/project/orchestration/templategeneratorpage.py b/heat_dashboard/test/integration/pages/project/orchestration/templategeneratorpage.py index e3fb555c..d3c084cf 100644 --- a/heat_dashboard/test/integration/pages/project/orchestration/templategeneratorpage.py +++ b/heat_dashboard/test/integration/pages/project/orchestration/templategeneratorpage.py @@ -17,5 +17,5 @@ from openstack_dashboard.test.integration_tests.pages import basepage class TemplategeneratorPage(basepage.BaseNavigationPage): def __init__(self, driver, conf): - super(TemplategeneratorPage, self).__init__(driver, conf) + super().__init__(driver, conf) self._page_title = "Template Generator" diff --git a/heat_dashboard/test/integration/pages/project/orchestration/templateversionspage.py b/heat_dashboard/test/integration/pages/project/orchestration/templateversionspage.py index 7c58ff56..1a5f9ee1 100644 --- a/heat_dashboard/test/integration/pages/project/orchestration/templateversionspage.py +++ b/heat_dashboard/test/integration/pages/project/orchestration/templateversionspage.py @@ -17,5 +17,5 @@ from openstack_dashboard.test.integration_tests.pages import basepage class TemplateversionsPage(basepage.BaseNavigationPage): def __init__(self, driver, conf): - super(TemplateversionsPage, self).__init__(driver, conf) + super().__init__(driver, conf) self._page_title = "Template Versions" diff --git a/heat_dashboard/test/test_data/glance_data.py b/heat_dashboard/test/test_data/glance_data.py index d028caf9..43ae1e3d 100644 --- a/heat_dashboard/test/test_data/glance_data.py +++ b/heat_dashboard/test/test_data/glance_data.py @@ -24,7 +24,7 @@ class Namespace(dict): return "" % self._info def __init__(self, info): - super(Namespace, self).__init__() + super().__init__() self.__dict__.update(info) self.update(info) self._info = info diff --git a/heat_dashboard/test/test_data/heat_data.py b/heat_dashboard/test/test_data/heat_data.py index 68b5a722..d98a8ff1 100644 --- a/heat_dashboard/test/test_data/heat_data.py +++ b/heat_dashboard/test/test_data/heat_data.py @@ -333,18 +333,18 @@ SNAPSHOT_CREATE = """ """ -class Environment(object): +class Environment: def __init__(self, data): self.data = data -class Template(object): +class Template: def __init__(self, data, validate): self.data = data self.validate = validate -class Snapshot(object): +class Snapshot: def __init__(self, data): self.data = data @@ -412,17 +412,17 @@ def data(TEST): 'AWS::StackId': ( 'arn:openstack:heat::2ce287:stacks/teststack/88553ec'), 'DBRootPassword': '******', - 'AWS::StackName': "teststack{0}".format(i), + 'AWS::StackName': "teststack{}".format(i), 'DBPassword': '******', 'AWS::Region': 'ap-southeast-1', 'DBName': 'wordpress' }, "stack_status_reason": "Stack successfully created", - "stack_name": "stack-test{0}".format(i), + "stack_name": "stack-test{}".format(i), "creation_time": "2013-04-22T00:11:39Z", "updated_time": "2013-04-22T00:11:39Z", "stack_status": "CREATE_COMPLETE", - "id": "05b4f39f-ea96-4d91-910c-e758c078a089{0}".format(i) + "id": "05b4f39f-ea96-4d91-910c-e758c078a089{}".format(i) } stack = stacks.Stack(stacks.StackManager(None), stack_data) TEST.stacks.add(stack) @@ -492,7 +492,7 @@ def data(TEST): "creation_time": "2016-02-21T04:02:54", "status_reason": "Stack SNAPSHOT completed successfully", - "id": "01558a3b-ba05-4427-bbb4-1e4ab71cfca{0}".format(i) + "id": "01558a3b-ba05-4427-bbb4-1e4ab71cfca{}".format(i) } TEST.stack_snapshot.add(snapshot_data) diff --git a/heat_dashboard/test/test_data/neutron_data.py b/heat_dashboard/test/test_data/neutron_data.py index 2003e8f8..3a9349b7 100644 --- a/heat_dashboard/test/test_data/neutron_data.py +++ b/heat_dashboard/test/test_data/neutron_data.py @@ -202,7 +202,7 @@ def data(TEST): 'id': '443a4d7a-4bd2-4474-9a77-02b35c9f8c95', 'name': 'another_group'} groups = [sec_group_1, sec_group_2, sec_group_3] - sg_name_dict = dict([(sg['id'], sg['name']) for sg in groups]) + sg_name_dict = {sg['id']: sg['name'] for sg in groups} for sg in groups: sg['security_group_rules'] = [] # OpenStack Dashboard internaly API. diff --git a/heat_dashboard/test/test_data/nova_data.py b/heat_dashboard/test/test_data/nova_data.py index 7ce09b3e..b37ca2a9 100644 --- a/heat_dashboard/test/test_data/nova_data.py +++ b/heat_dashboard/test/test_data/nova_data.py @@ -27,7 +27,7 @@ class FlavorExtraSpecs(dict): return "" % self._info def __init__(self, info): - super(FlavorExtraSpecs, self).__init__() + super().__init__() self.__dict__.update(info) self.update(info) self._info = info diff --git a/heat_dashboard/test/test_data/utils.py b/heat_dashboard/test/test_data/utils.py index e7b1df92..51a7eb9f 100644 --- a/heat_dashboard/test/test_data/utils.py +++ b/heat_dashboard/test/test_data/utils.py @@ -41,7 +41,7 @@ def load_test_data(load_onto=None): return TestData(*loaders) -class TestData(object): +class TestData: """Holder object for test data. Any functions passed to the init method will be called with the @@ -69,7 +69,7 @@ class TestData(object): data_func(self) -class TestDataContainer(object): +class TestDataContainer: """A container for test data objects. The behavior of this class is meant to mimic a "manager" class, which diff --git a/heat_dashboard/test/tests/content/test_stacks.py b/heat_dashboard/test/tests/content/test_stacks.py index adea18bf..2bbf0484 100644 --- a/heat_dashboard/test/tests/content/test_stacks.py +++ b/heat_dashboard/test/tests/content/test_stacks.py @@ -34,7 +34,7 @@ INDEX_URL = reverse('horizon:project:stacks:index') DETAIL_URL = 'horizon:project:stacks:detail' -class MockResource(object): +class MockResource: def __init__(self, resource_type, physical_resource_id): self.resource_type = resource_type self.physical_resource_id = physical_resource_id @@ -132,17 +132,17 @@ class StackTests(test.TestCase): self.assertEqual(len(res.context['stacks_table'].data), settings.API_RESULT_PAGE_SIZE) - url = "%s?%s=%s" % (reverse('horizon:project:stacks:index'), - tables.StacksTable._meta.pagination_param, - stacks[2].id) + url = "{}?{}={}".format(reverse('horizon:project:stacks:index'), + tables.StacksTable._meta.pagination_param, + stacks[2].id) res = self.client.get(url) # get second page (items 2-4) self.assertEqual(len(res.context['stacks_table'].data), settings.API_RESULT_PAGE_SIZE) - url = "%s?%s=%s" % (reverse('horizon:project:stacks:index'), - tables.StacksTable._meta.pagination_param, - stacks[4].id) + url = "{}?{}={}".format(reverse('horizon:project:stacks:index'), + tables.StacksTable._meta.pagination_param, + stacks[4].id) res = self.client.get(url) # get third page (item 5) self.assertEqual(len(res.context['stacks_table'].data), @@ -172,16 +172,16 @@ class StackTests(test.TestCase): self.assertEqual(len(res.context['stacks_table'].data), settings.API_RESULT_PAGE_SIZE) - url = "%s?%s=%s" % (reverse('horizon:project:stacks:index'), - tables.StacksTable._meta.pagination_param, - stacks[2].id) + url = "{}?{}={}".format(reverse('horizon:project:stacks:index'), + tables.StacksTable._meta.pagination_param, + stacks[2].id) res = self.client.get(url) # get second page (item 3) self.assertEqual(len(res.context['stacks_table'].data), 1) - url = "%s?%s=%s" % (reverse('horizon:project:stacks:index'), - tables.StacksTable._meta.prev_pagination_param, - stacks[2].id) + url = "{}?{}={}".format(reverse('horizon:project:stacks:index'), + tables.StacksTable._meta.prev_pagination_param, + stacks[2].id) res = self.client.get(url) # prev back to get first page with 2 pages self.assertEqual(len(res.context['stacks_table'].data), @@ -840,7 +840,7 @@ class StackTests(test.TestCase): class TemplateFormTests(test.TestCase): - class SimpleFile(object): + class SimpleFile: def __init__(self, name, data): self.name = name self.data = data diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index 9172e92f..e3f9c009 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at