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.

Also introduce pre-commit and its pyupgrade hook to avoid merging
additional Python 2 syntaxes.

Change-Id: I12d2ccc679e0fcb3e3f467ee59da0aabb61a04a2
This commit is contained in:
Takashi Kajinami
2025-01-13 13:46:57 +09:00
parent b265abeaad
commit fac6e36428
6 changed files with 9 additions and 8 deletions

View File

@@ -23,3 +23,8 @@ repos:
hooks:
- id: hacking
additional_dependencies: []
- repo: https://github.com/asottile/pyupgrade
rev: v3.18.0
hooks:
- id: pyupgrade
args: [--py3-only]

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2020 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@@ -28,7 +28,7 @@ from oslo_upgradecheck import upgradecheck
class TestUpgradeCheckPolicyJSON(base.BaseTestCase):
def setUp(self):
super(TestUpgradeCheckPolicyJSON, self).setUp()
super().setUp()
conf_fixture = self.useFixture(config.Config())
conf_fixture.load_raw_values()
self.conf = conf_fixture.conf

View File

@@ -1,5 +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

View File

@@ -50,7 +50,7 @@ UPGRADE_CHECK_MSG_MAP = {
}
class Result(object):
class Result:
"""Class used for 'nova-status upgrade check' results.
The 'code' attribute is a Code enum.
@@ -60,12 +60,12 @@ class Result(object):
"""
def __init__(self, code, details=None):
super(Result, self).__init__()
super().__init__()
self.code = code
self.details = details
class UpgradeCommands(object):
class UpgradeCommands:
"""Base class for upgrade checks
This class should be inherited by a class in each project that provides

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2020 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may