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.

Change-Id: Iee7bdff54efe4bea1b255c1114a4291c3e62fea0
This commit is contained in:
Takashi Kajinami 2024-10-19 23:26:59 +09:00
parent 82d872cc99
commit 066baeb179
10 changed files with 11 additions and 11 deletions

View File

@ -24,3 +24,8 @@ repos:
- id: hacking
additional_dependencies: []
exclude: '^(doc|releasenotes|tools)/.*$'
- 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 -*-
#
# etcd3-gateway documentation build configuration file, created by
# sphinx-quickstart on Sat Mar 25 20:42:09 2017.

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
@ -12,7 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import
import pbr.version
from etcd3gw.client import client

View File

@ -41,7 +41,7 @@ _EXCEPTIONS_BY_CODE = {
DEFAULT_API_PATH = os.getenv('ETCD3GW_API_PATH')
class Etcd3Client(object):
class Etcd3Client:
def __init__(self, host='localhost', port=2379, protocol="http",
ca_cert=None, cert_key=None, cert_cert=None, timeout=None,
api_path=DEFAULT_API_PATH):

View File

@ -13,7 +13,7 @@
class Etcd3Exception(Exception):
def __init__(self, detail_text=None, *args):
super(Etcd3Exception, self).__init__(*args)
super().__init__(*args)
self.detail_text = detail_text

View File

@ -13,7 +13,7 @@
from etcd3gw.utils import _decode
class Lease(object):
class Lease:
def __init__(self, id, client=None):
"""Lease object for expiring keys

View File

@ -17,7 +17,7 @@ from etcd3gw.utils import DEFAULT_TIMEOUT
from etcd3gw.utils import LOCK_PREFIX
class Lock(object):
class Lock:
def __init__(self, name, ttl=DEFAULT_TIMEOUT, client=None):
"""Create a lock using the given name with specified timeout

View File

@ -360,7 +360,7 @@ class TestEtcd3Gateway(base.TestCase):
self.assertEqual(
event['kv']['key'],
('%s%s' % (key, change_count)).encode("latin-1"),
('{}{}'.format(key, change_count)).encode("latin-1"),
)
self.assertEqual(
event['kv']['value'],

View File

@ -39,7 +39,7 @@ def _watch(resp, callback):
callback(event)
class Watcher(object):
class Watcher:
KW_ARGS = ['start_revision', 'progress_notify', 'filters', 'prev_kv']
KW_ENCODED_ARGS = ['range_end']

View File

@ -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