Skip to content

Commit

Permalink
Drop explicit inheritance from 'object' class
Browse files Browse the repository at this point in the history
This was necessary in Python 2 to force new-style classes.
In Python 3, it's just noise.

Substitutions were done automatically with 'sed', except:
- twisted/words/xish/xpathparser.g was done by hand and
  xpathparser.py was re-generated from that
- twisted/test/test_plugin.py was done by hand
  • Loading branch information
mthuurne committed Aug 8, 2020
1 parent 78032af commit f6e0c42
Show file tree
Hide file tree
Showing 308 changed files with 884 additions and 884 deletions.
2 changes: 1 addition & 1 deletion src/twisted/_threads/_convenience.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ._ithreads import AlreadyQuit


class Quit(object):
class Quit:
"""
A flag representing whether a worker has been quit.
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/_threads/_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
NoMoreWork = object()

@implementer(IWorker)
class MemoryWorker(object):
class MemoryWorker:
"""
An L{IWorker} that queues work for later performance.
Expand Down
4 changes: 2 additions & 2 deletions src/twisted/_threads/_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@



class Statistics(object):
class Statistics:
"""
Statistics about a L{Team}'s current activity.
Expand All @@ -41,7 +41,7 @@ def __init__(self, idleWorkerCount, busyWorkerCount,


@implementer(IWorker)
class Team(object):
class Team:
"""
A composite L{IWorker} implementation.
Expand Down
4 changes: 2 additions & 2 deletions src/twisted/_threads/_threadworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
_stop = object()

@implementer(IExclusiveWorker)
class ThreadWorker(object):
class ThreadWorker:
"""
An L{IExclusiveWorker} implemented based on a single thread and a queue.
Expand Down Expand Up @@ -68,7 +68,7 @@ def quit(self):


@implementer(IExclusiveWorker)
class LockWorker(object):
class LockWorker:
"""
An L{IWorker} implemented based on a mutual-exclusion lock.
"""
Expand Down
6 changes: 3 additions & 3 deletions src/twisted/_threads/test/test_threadworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class WouldDeadlock(Exception):



class FakeThread(object):
class FakeThread:
"""
A fake L{threading.Thread}.
Expand All @@ -56,7 +56,7 @@ def start(self):



class FakeQueue(object):
class FakeQueue:
"""
A fake L{Queue} implementing C{put} and C{get}.
Expand Down Expand Up @@ -93,7 +93,7 @@ def get(self):



class FakeLock(object):
class FakeLock:
"""
A stand-in for L{threading.Lock}.
Expand Down
8 changes: 4 additions & 4 deletions src/twisted/application/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from twisted.application.reactors import NoSuchReactor


class _BasicProfiler(object):
class _BasicProfiler:
"""
@ivar saveStats: if C{True}, save the stats information instead of the
human readable format
Expand Down Expand Up @@ -114,7 +114,7 @@ def run(self, reactor):



class AppProfiler(object):
class AppProfiler:
"""
Class which selects a specific profile runner based on configuration
options.
Expand All @@ -137,7 +137,7 @@ def __init__(self, options):



class AppLogger(object):
class AppLogger:
"""
An L{AppLogger} attaches the configured log observer specified on the
commandline to a L{ServerOptions} object, a custom L{logger.ILogObserver},
Expand Down Expand Up @@ -340,7 +340,7 @@ def getSavePassphrase(needed):



class ApplicationRunner(object):
class ApplicationRunner:
"""
An object which helps running an application based on a config object.
Expand Down
10 changes: 5 additions & 5 deletions src/twisted/application/internet.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def stopService(self):



class StreamServerEndpointService(service.Service, object):
class StreamServerEndpointService(service.Service):
"""
A L{StreamServerEndpointService} is an L{IService} which runs a server on a
listening port described by an L{IStreamServerEndpoint
Expand Down Expand Up @@ -446,7 +446,7 @@ def stop(passthrough):



class _ReconnectingProtocolProxy(object):
class _ReconnectingProtocolProxy:
"""
A proxy for a Protocol to provide connectionLost notification to a client
connection service, in support of reconnecting when connections are lost.
Expand Down Expand Up @@ -493,7 +493,7 @@ def __repr__(self) -> str:



class _DisconnectFactory(object):
class _DisconnectFactory:
"""
A L{_DisconnectFactory} is a proxy for L{IProtocolFactory} that catches
C{connectionLost} notifications and relays them.
Expand Down Expand Up @@ -590,7 +590,7 @@ def _firstResult(gen):



class _ClientMachine(object):
class _ClientMachine:
"""
State machine for maintaining a single outgoing connection to an endpoint.
Expand Down Expand Up @@ -1077,7 +1077,7 @@ def _deliverConnectionFailure(self, f):



class ClientService(service.Service, object):
class ClientService(service.Service):
"""
A L{ClientService} maintains a single outgoing connection to a client
endpoint, reconnecting after a configurable timeout when a connection
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/application/reactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class NoSuchReactor(KeyError):


@implementer(IPlugin, IReactorInstaller)
class Reactor(object):
class Reactor:
"""
@ivar moduleName: The fully-qualified Python name of the module of which
the install callable is an attribute.
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/application/runner/_exit.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def exit(status, message=None):
try:
import posix as Status
except ImportError:
class Status(object): # type: ignore[no-redef]
class Status: # type: ignore[no-redef]
"""
Object to hang C{EX_*} values off of as a substitute for L{posix}.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/twisted/application/runner/_pidfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __exit__(excType, excValue, traceback):


@implementer(IPIDFile)
class PIDFile(object):
class PIDFile:
"""
Concrete implementation of L{IPIDFile} based on C{IFilePath}.
Expand Down Expand Up @@ -220,7 +220,7 @@ def __exit__(self, excType, excValue, traceback):


@implementer(IPIDFile)
class NonePIDFile(object):
class NonePIDFile:
"""
PID file implementation that does nothing.
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/application/runner/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


@attrs(frozen=True)
class Runner(object):
class Runner:
"""
Twisted application runner.
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/application/runner/test/test_exit.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_exitMessageNonZero(self):



class DummyExit(object):
class DummyExit:
"""
Stub for L{sys.exit} that remembers whether it's been called and, if it
has, what argument it was given.
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/application/runner/test/test_pidfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def test_contextManager(self):


@implementer(IFilePath)
class DummyFilePath(object):
class DummyFilePath:
"""
In-memory L{IFilePath}.
"""
Expand Down
10 changes: 5 additions & 5 deletions src/twisted/application/runner/test/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_startLogging(self):
# Patch the log beginner so that we don't try to start the already
# running (started by trial) logging system.

class LogBeginner(object):
class LogBeginner:
def beginLoggingTo(self, observers):
LogBeginner.observers = observers

Expand Down Expand Up @@ -401,7 +401,7 @@ def __exit__(self, excType, excValue, traceback):



class DummyExit(object):
class DummyExit:
"""
Stub for L{exit} that remembers whether it's been called and, if it has,
what arguments it was given.
Expand All @@ -420,7 +420,7 @@ def __call__(self, status, message=None):



class DummyKill(object):
class DummyKill:
"""
Stub for L{os.kill} that remembers whether it's been called and, if it has,
what arguments it was given.
Expand All @@ -435,7 +435,7 @@ def __call__(self, pid, sig):



class DummyStandardIO(object):
class DummyStandardIO:
"""
Stub for L{sys} which provides L{BytesIO} streams as stdout and stderr.
"""
Expand All @@ -446,7 +446,7 @@ def __init__(self, stdout, stderr):



class DummyWarningsModule(object):
class DummyWarningsModule:
"""
Stub for L{warnings} which provides a C{showwarning} method that is a no-op.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/twisted/application/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def makeService(options):


@implementer(IPlugin, IServiceMaker)
class ServiceMaker(object):
class ServiceMaker:
"""
Utility class to simplify the definition of L{IServiceMaker} plugins.
"""
Expand Down Expand Up @@ -154,7 +154,7 @@ def privilegedStartService():


@implementer(IService)
class Service(object):
class Service:
"""
Base class for services.
Expand Down
12 changes: 6 additions & 6 deletions src/twisted/application/test/test_internet.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def fakeTargetFunction():


@implementer(IStreamServerEndpoint)
class FakeServer(object):
class FakeServer:
"""
In-memory implementation of L{IStreamServerEndpoint}.
Expand Down Expand Up @@ -112,7 +112,7 @@ def stoppedListening(self):


@implementer(IListeningPort)
class FakePort(object):
class FakePort:
"""
Fake L{IListeningPort} implementation.
Expand Down Expand Up @@ -453,7 +453,7 @@ def test_pickleTimerServiceNotPickleLoopFinished(self):



class ConnectInformation(object):
class ConnectInformation:
"""
Information about C{endpointForTesting}
Expand Down Expand Up @@ -485,7 +485,7 @@ def endpointForTesting(fireImmediately=False):
C{endpoint}.
"""
@implementer(IStreamClientEndpoint)
class ClientTestEndpoint(object):
class ClientTestEndpoint:
def connect(self, factory):
result = Deferred()
info.passedFactories.append(factory)
Expand Down Expand Up @@ -572,7 +572,7 @@ def makeReconnector(self, fireImmediately=True, startService=True,

applicationProtocols = cq.applicationProtocols = []

class RememberingFactory(Factory, object):
class RememberingFactory(Factory):
protocol = protocolType
def buildProtocol(self, addr):
result = super(RememberingFactory, self).buildProtocol(addr)
Expand Down Expand Up @@ -704,7 +704,7 @@ def test_interfacesForTransport(self):
the reactor.
"""
@implementer(IHalfCloseableProtocol, IFileDescriptorReceiver)
class FancyProtocol(Protocol, object):
class FancyProtocol(Protocol):
"""
Provider of various interfaces.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/application/test/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


@implementer(IService)
class AlmostService(object):
class AlmostService:
"""
Implement IService in a way that can fail.
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/application/twist/_twist.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@



class Twist(object):
class Twist:
"""
Run a Twisted application.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/twisted/application/twist/test/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def test_selectDefaultLogObserverDefaultWithTTY(self):
L{TwistOptions.selectDefaultLogObserver} will not override an already
selected observer.
"""
class TTYFile(object):
class TTYFile:
def isatty(self):
return True

Expand Down
2 changes: 1 addition & 1 deletion src/twisted/application/twist/test/test_twist.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_main(self):

runners = []

class Runner(object):
class Runner:
def __init__(self, **kwargs):
self.args = kwargs
self.runs = 0
Expand Down
Loading

0 comments on commit f6e0c42

Please sign in to comment.