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 - id: hacking
additional_dependencies: [] additional_dependencies: []
exclude: '^(doc|releasenotes|tools)/.*$' 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 # etcd3-gateway documentation build configuration file, created by
# sphinx-quickstart on Sat Mar 25 20:42:09 2017. # 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 # 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 # not use this file except in compliance with the License. You may obtain
# a copy of the License at # a copy of the License at
@ -12,7 +10,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from __future__ import absolute_import
import pbr.version import pbr.version
from etcd3gw.client import client from etcd3gw.client import client

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at