Skip to content

Commit

Permalink
Stop using twisted.internet.defer.returnValue
Browse files Browse the repository at this point in the history
`defer.returnValue` was only needed in Python 2; in Python 3, a simple
`return` is fine.

`twisted.internet.defer.returnValue` is deprecated as of Twisted 24.7.0.
  • Loading branch information
cjwatson committed Dec 9, 2024
1 parent f7f3bcf commit 9e9bdaa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/foolscap/connections/tor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os, re
import six
from twisted.internet.interfaces import IStreamClientEndpoint
from twisted.internet.defer import inlineCallbacks, returnValue, succeed
from twisted.internet.defer import inlineCallbacks, succeed
from twisted.internet.endpoints import clientFromString
import ipaddress
from .. import observer
Expand Down Expand Up @@ -71,7 +71,7 @@ def hint_to_endpoint(self, hint, reactor, update_status):
socks_endpoint = yield self._maybe_connect(reactor, update_status)
ep = txtorcon.TorClientEndpoint(host, portnum,
socks_endpoint=socks_endpoint)
returnValue( (ep, host) )
return ep, host

def describe(self):
return "tor"
Expand Down Expand Up @@ -133,7 +133,7 @@ def _connect(self, reactor, update_status):
#print "launched"
# gives a TorProcessProtocol with .tor_protocol
self._tor_protocol = tpp.tor_protocol
returnValue(socks_endpoint)
return socks_endpoint

def launch(data_directory=None, tor_binary=None):
"""Return a handler which launches a new Tor process (once).
Expand Down Expand Up @@ -189,7 +189,7 @@ def _connect(self, reactor, update_status):
try:
(socks_endpoint, socks_desc) = next(find_port(reactor, ports))
self._socks_desc = socks_desc # stash for tests
returnValue(socks_endpoint)
return socks_endpoint
except StopIteration:
raise ValueError("could not use config.SocksPort: %r" % (ports,))

Expand Down
4 changes: 2 additions & 2 deletions src/foolscap/logging/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import six
from six.moves.urllib.parse import quote
from twisted.internet import reactor, endpoints
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.internet.defer import inlineCallbacks
from twisted.python import usage
from foolscap import base32
from foolscap.eventual import fireEventually
Expand Down Expand Up @@ -395,7 +395,7 @@ def start(self, options):
import webbrowser
webbrowser.open(url)

returnValue(url) # for tests
return url # for tests

def stop(self):
return self.lp.stopListening()
Expand Down
4 changes: 2 additions & 2 deletions src/foolscap/test/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from twisted.trial import unittest
from twisted.application import service
from twisted.internet import defer, reactor
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.internet.defer import inlineCallbacks
try:
from twisted import logger as twisted_logger
except ImportError:
Expand Down Expand Up @@ -2332,7 +2332,7 @@ def getPage(url):
if response.code != 200:
raise ValueError("request failed (%d), page contents were: %s" % (
response.code, six.ensure_str(page)))
returnValue(page)
return page

class Web(unittest.TestCase):
def setUp(self):
Expand Down
4 changes: 2 additions & 2 deletions src/foolscap/test/test_negotiate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from twisted.trial import unittest

from twisted.internet import protocol, defer, reactor
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.internet.defer import inlineCallbacks
from twisted.application import internet
from twisted.web.client import Agent
from foolscap import negotiate, tokens
Expand Down Expand Up @@ -386,7 +386,7 @@ def connect2(self):
# connection to be dropped, which will happen shortly after the
# forward direction is established (but after some network traffic).
yield self.poll(lambda: self.tub2phases)
returnValue(rref1)
return rref1

def checkConnectedViaReverse(self, rref, targetPhases):
# assert that connection[0] (from tub1 to tub2) is actually in use.
Expand Down

0 comments on commit 9e9bdaa

Please sign in to comment.