Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove python 2 new-style classes as only python 3.5+ is supported now #2836

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/frameworks/cherryapp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cherrypy


class Root(object):
class Root:
@cherrypy.expose
def index(self):
return 'Hello World!'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def child_process(queue):
requests.get('http://requestb.in/15s95oz1')


class GunicornSubProcessTestMiddleware(object):
class GunicornSubProcessTestMiddleware:
def __init__(self):
super().__init__()
self.queue = Queue()
Expand Down
2 changes: 1 addition & 1 deletion examples/longpoll.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys
import time

class TestIter(object):
class TestIter:

def __iter__(self):
lines = [b'line 1\n', b'line 2\n']
Expand Down
2 changes: 1 addition & 1 deletion examples/multiapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from test import app as app2


class Application(object):
class Application:
def __init__(self):
self.map = Mapper()
self.map.connect('app1', '/app1url', app=app1)
Expand Down
4 changes: 2 additions & 2 deletions examples/websocket/gevent_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

WS_KEY = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"

class WebSocketWSGI(object):
class WebSocketWSGI:
def __init__(self, handler):
self.handler = handler

Expand Down Expand Up @@ -118,7 +118,7 @@ def __call__(self, environ, start_response):
# doesn't barf on the fact that we didn't call start_response
return ALREADY_HANDLED

class WebSocket(object):
class WebSocket:
"""A websocket object that handles the details of
serialization/deserialization to the socket.

Expand Down
4 changes: 2 additions & 2 deletions examples/websocket/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

WS_KEY = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"

class WebSocketWSGI(object):
class WebSocketWSGI:
def __init__(self, handler):
self.handler = handler

Expand Down Expand Up @@ -119,7 +119,7 @@ def __call__(self, environ, start_response):
# doesn't barf on the fact that we didn't call start_response
return ALREADY_HANDLED

class WebSocket(object):
class WebSocket:
"""A websocket object that handles the details of
serialization/deserialization to the socket.

Expand Down
2 changes: 1 addition & 1 deletion gunicorn/app/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from gunicorn import debug


class BaseApplication(object):
class BaseApplication:
"""
An application interface for configuring and loading
the various necessities for any given web framework.
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/arbiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from gunicorn import __version__, SERVER_SOFTWARE


class Arbiter(object):
class Arbiter:
"""
Arbiter maintain the workers processes alive. It launches or
kills them if needed. It also manages application reloading
Expand Down
4 changes: 2 additions & 2 deletions gunicorn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def auto_int(_, x):
return int(x, 0)


class Config(object):
class Config:

def __init__(self, usage=None, prog=None):
self.settings = make_settings()
Expand Down Expand Up @@ -253,7 +253,7 @@ def fmt_desc(cls, desc):
setattr(cls, "short", desc.splitlines()[0])


class Setting(object):
class Setting:
name = None
value = None
section = None
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
_token_spliter = re.compile(r'\W+')


class Spew(object):
class Spew:

def __init__(self, trace_names=None, show_values=True):
self.trace_names = trace_names
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/glogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def parse_syslog_address(addr):
return (socktype, (host, port))


class Logger(object):
class Logger:

LOG_LEVELS = {
"critical": logging.CRITICAL,
Expand Down
8 changes: 4 additions & 4 deletions gunicorn/http/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
InvalidChunkSize)


class ChunkedReader(object):
class ChunkedReader:
def __init__(self, req, unreader):
self.req = req
self.parser = self.parse_chunked(unreader)
Expand Down Expand Up @@ -106,7 +106,7 @@ def get_data(self, unreader, buf):
buf.write(data)


class LengthReader(object):
class LengthReader:
def __init__(self, unreader, length):
self.unreader = unreader
self.length = length
Expand Down Expand Up @@ -136,7 +136,7 @@ def read(self, size):
return ret


class EOFReader(object):
class EOFReader:
def __init__(self, unreader):
self.unreader = unreader
self.buf = io.BytesIO()
Expand Down Expand Up @@ -174,7 +174,7 @@ def read(self, size):
return ret


class Body(object):
class Body:
def __init__(self, reader):
self.reader = reader
self.buf = io.BytesIO()
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/http/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
VERSION_RE = re.compile(r"HTTP/(\d+)\.(\d+)")


class Message(object):
class Message:
def __init__(self, cfg, unreader, peer_addr):
self.cfg = cfg
self.unreader = unreader
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/http/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from gunicorn.http.unreader import SocketUnreader, IterUnreader


class Parser(object):
class Parser:

mesg_class = None

Expand Down
2 changes: 1 addition & 1 deletion gunicorn/http/unreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# a given type of data source.


class Unreader(object):
class Unreader:
def __init__(self):
self.buf = io.BytesIO()

Expand Down
4 changes: 2 additions & 2 deletions gunicorn/http/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
log = logging.getLogger(__name__)


class FileWrapper(object):
class FileWrapper:

def __init__(self, filelike, blksize=8192):
self.filelike = filelike
Expand Down Expand Up @@ -190,7 +190,7 @@ def create(req, sock, client, server, cfg):
return resp, environ


class Response(object):
class Response:

def __init__(self, req, sock, cfg):
self.req = req
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/pidfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import tempfile


class Pidfile(object):
class Pidfile:
"""\
Manage a PID file. If a specific name is provided
it and '"%s.oldpid" % name' will be used. Otherwise
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def run(self):

else:

class InotifyReloader(object):
class InotifyReloader:
def __init__(self, callback=None):
raise ImportError('You must have the inotify module installed to '
'use the inotify reloader')
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/sock.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from gunicorn import util


class BaseSocket(object):
class BaseSocket:

def __init__(self, address, conf, log, fd=None):
self.log = log
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/workers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from gunicorn.workers.workertmp import WorkerTmp


class Worker(object):
class Worker:

SIGNALS = [getattr(signal, "SIG%s" % x) for x in (
"ABRT HUP QUIT INT TERM USR1 USR2 WINCH CHLD".split()
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/workers/ggevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def init_process(self):
super().init_process()


class GeventResponse(object):
class GeventResponse:

status = None
headers = None
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/workers/gthread.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from ..http import wsgi


class TConn(object):
class TConn:

def __init__(self, cfg, sock, client, server):
self.cfg = cfg
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/workers/workertmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
IS_CYGWIN = PLATFORM.startswith('CYGWIN')


class WorkerTmp(object):
class WorkerTmp:

def __init__(self, cfg):
old_umask = os.umask(cfg.umask)
Expand Down
4 changes: 2 additions & 2 deletions tests/t.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def data_source(fname):
return buf


class request(object):
class request:
def __init__(self, name):
self.fname = os.path.join(dirname, "requests", name)

Expand All @@ -34,7 +34,7 @@ def run():
return run


class FakeSocket(object):
class FakeSocket:

def __init__(self, data):
self.tmp = tempfile.TemporaryFile()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def paster_ini():
return os.path.join(dirname, "..", "examples", "frameworks", "pylonstest", "nose.ini")


class AltArgs(object):
class AltArgs:
def __init__(self, args=None):
self.args = args or []
self.orig = sys.argv
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_property_access():
# Not a config property
pytest.raises(AttributeError, getattr, c, "foo")
# Force to be not an error
class Baz(object):
class Baz:
def get(self):
return 3.14
c.settings["foo"] = Baz()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class StatsdTestException(Exception):
pass


class MockSocket(object):
class MockSocket:
"Pretend to be a UDP socket"
def __init__(self, failp):
self.failp = failp
Expand Down
4 changes: 2 additions & 2 deletions tests/treq.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def load_py(fname):
return vars(mod)


class request(object):
class request:
def __init__(self, fname, expect):
self.fname = fname
self.name = os.path.basename(fname)
Expand Down Expand Up @@ -262,7 +262,7 @@ def same(self, req, sizer, matcher, exp):
assert req.trailers == exp.get("trailers", [])


class badrequest(object):
class badrequest:
def __init__(self, fname):
self.fname = fname
self.name = os.path.basename(fname)
Expand Down