Merge "Run pyupgrade to clean up Python 2 syntaxes"

This commit is contained in:
Zuul
2025-05-12 16:16:31 +00:00
committed by Gerrit Code Review
7 changed files with 15 additions and 16 deletions

View File

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

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

View File

@@ -100,7 +100,7 @@ def _log_and_ignore_error(fn):
return wrapper return wrapper
class InputProxy(object): class InputProxy:
"""File-like object that counts bytes read. """File-like object that counts bytes read.
To be swapped in for wsgi.input for accounting purposes. To be swapped in for wsgi.input for accounting purposes.
@@ -147,7 +147,7 @@ class KeystoneClientLoader(ksa_adapter.Adapter):
return ks_client.Client return ks_client.Client
class Swift(object): class Swift:
"""Swift middleware used for counting requests.""" """Swift middleware used for counting requests."""
event_queue = None event_queue = None
@@ -416,7 +416,7 @@ class Swift(object):
class SendEventThread(threading.Thread): class SendEventThread(threading.Thread):
def __init__(self, notifier): def __init__(self, notifier):
super(SendEventThread, self).__init__() super().__init__()
self.notifier = notifier self.notifier = notifier
def run(self): def run(self):

View File

@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2010-2011 OpenStack Foundation # Copyright 2010-2011 OpenStack Foundation
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. # Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
# #

View File

@@ -24,7 +24,7 @@ from ceilometermiddleware.tests import base as tests_base
from keystoneauth1.fixture import keystoneauth_betamax as betamax from keystoneauth1.fixture import keystoneauth_betamax as betamax
class FakeApp(object): class FakeApp:
def __init__(self, body=None): def __init__(self, body=None):
self.body = body or ['This string is 28 bytes long'] self.body = body or ['This string is 28 bytes long']
@@ -36,11 +36,10 @@ class FakeApp(object):
]) ])
while env['wsgi.input'].read(5): while env['wsgi.input'].read(5):
pass pass
for line in self.body: yield from self.body
yield line
class FakeRequest(object): class FakeRequest:
"""A bare bones request object """A bare bones request object
The middleware will inspect this for request method, The middleware will inspect this for request method,
@@ -65,7 +64,7 @@ class FakeRequest(object):
class TestSwift(tests_base.TestCase): class TestSwift(tests_base.TestCase):
def setUp(self): def setUp(self):
super(TestSwift, self).setUp() super().setUp()
cfg.CONF([], project='ceilometermiddleware') cfg.CONF([], project='ceilometermiddleware')
self.addCleanup(cfg.CONF.reset) self.addCleanup(cfg.CONF.reset)
@@ -261,7 +260,7 @@ class TestSwift(tests_base.TestCase):
app = swift.Swift(FakeApp(), { app = swift.Swift(FakeApp(), {
'metadata_headers': 'unicode' 'metadata_headers': 'unicode'
}) })
uni = u'\xef\xbd\xa1\xef\xbd\xa5' uni = '\xef\xbd\xa1\xef\xbd\xa5'
req = self.get_request('/1.0/account/container', req = self.get_request('/1.0/account/container',
environ={'REQUEST_METHOD': 'GET'}, environ={'REQUEST_METHOD': 'GET'},
headers={'UNICODE': uni}) headers={'UNICODE': uni})

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

View File

@@ -54,8 +54,8 @@ master_doc = 'index'
# General information about the project. # General information about the project.
author = 'Ceilometer Middleware Contributors' author = 'Ceilometer Middleware Contributors'
category = 'Miscellaneous' category = 'Miscellaneous'
copyright = u'2016, Ceilometer Middleware Developers' copyright = '2016, Ceilometer Middleware Developers'
project = u'Ceilometer Middleware Release Notes' project = 'Ceilometer Middleware Release Notes'
description = 'Ceilometer Middleware publishes traffic measures for Swift.' description = 'Ceilometer Middleware publishes traffic measures for Swift.'
title = 'Ceilometer Middleware Release Notes' title = 'Ceilometer Middleware Release Notes'
target_name = 'ceilometermiddleware' target_name = 'ceilometermiddleware'