Skip to content

trim usage of "six" #117

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

Merged
merged 1 commit into from
Feb 22, 2025
Merged
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
trim usage of "six"
  • Loading branch information
a-detiste committed Feb 22, 2025
commit f70c4bfade3c05ad0a22fbd1ebe3732994ed1d59
2 changes: 1 addition & 1 deletion src/foolscap/banana.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@

def int2b128(integer, stream):
if integer == 0:
stream(six.int2byte(0))
stream(b'\0')
return
assert integer > 0, "can only encode positive integers"
while integer:
3 changes: 1 addition & 2 deletions src/foolscap/copyable.py
Original file line number Diff line number Diff line change
@@ -340,8 +340,7 @@ class RemoteCopyOldStyle(_RemoteCopyBase):
# classes do not do metaclass magic
copytype = None

@six.add_metaclass(RemoteCopyClass)
class RemoteCopy(_RemoteCopyBase, object):
class RemoteCopy(_RemoteCopyBase, metaclass=RemoteCopyClass):
# Set 'copytype' to a unique string that is shared between the
# sender-side Copyable and the receiver-side RemoteCopy. This RemoteCopy
# subclass will be auto-registered using the 'copytype' name. Set
2 changes: 1 addition & 1 deletion src/foolscap/pb.py
Original file line number Diff line number Diff line change
@@ -513,7 +513,7 @@ def listenOn(self, what, _test_options={}):
"port numbers instead")
warn(warningString, DeprecationWarning, stacklevel=2)

if isinstance(what, six.string_types) and re.search(r"^\d+$", what):
if isinstance(what, str) and re.search(r"^\d+$", what):
warn("Tub.listenOn('12345') was deprecated "
"in Foolscap 0.12.0; please use qualified endpoint "
"descriptions like 'tcp:12345'",
3 changes: 1 addition & 2 deletions src/foolscap/remoteinterface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import six
import types
import inspect
from zope.interface import interface, providedBy, implementer
@@ -414,5 +413,5 @@ def _makeConstraint(t):
# See
# https://github.com/warner/foolscap/pull/76/commits/ff3b9e8c1e4fa13701273a2143ba80b1e58f47cf#r549428977
# for more background on the use of add_metaclass here.
class RemoteInterface(six.with_metaclass(RemoteInterfaceClass, interface.Interface)):
class RemoteInterface(interface.Interface, metaclass=RemoteInterfaceClass):
pass
6 changes: 2 additions & 4 deletions src/foolscap/slicer.py
Original file line number Diff line number Diff line change
@@ -19,9 +19,8 @@ def __init__(self, name, bases, dict):
if typ:
registerAdapter(self, typ, tokens.ISlicer)

@six.add_metaclass(SlicerClass)
@implementer(tokens.ISlicer)
class BaseSlicer(object):
class BaseSlicer(metaclass=SlicerClass):
slices = None

parent = None
@@ -146,9 +145,8 @@ def __init__(self, name, bases, dict):
if opentype:
registerUnslicer(opentype, self, reg)

@six.add_metaclass(UnslicerClass)
@implementer(tokens.IUnslicer)
class BaseUnslicer(object):
class BaseUnslicer(metaclass=UnslicerClass):
opentype = None

def __init__(self):
2 changes: 1 addition & 1 deletion src/foolscap/test/test_banana.py
Original file line number Diff line number Diff line change
@@ -142,7 +142,7 @@ def untokenize(tokens):
elif isinstance(t, float):
data.append(FLOAT)
data.append(struct.pack("!d", t))
elif isinstance(t, six.string_types) or isinstance(t, bytes):
elif isinstance(t, (str, bytes)):
t = six.ensure_binary(t)
int2b128(len(t), data.append)
data.append(STRING)
29 changes: 14 additions & 15 deletions src/foolscap/tokens.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import six
from twisted.python.failure import Failure
from zope.interface import Attribute, Interface

# delimiter characters.
LIST = six.int2byte(0x80) # old
INT = six.int2byte(0x81)
STRING = six.int2byte(0x82)
NEG = six.int2byte(0x83)
FLOAT = six.int2byte(0x84)
LIST = b'\x80' # old
INT = b'\x81'
STRING = b'\x82'
NEG = b'\x83'
FLOAT = b'\x84'
# "optional" -- these might be refused by a low-level implementation.
LONGINT = six.int2byte(0x85) # old
LONGNEG = six.int2byte(0x86) # old
LONGINT = b'\x85' # old
LONGNEG = b'\x86' # old
# really optional; this is is part of the 'pb' vocabulary
VOCAB = six.int2byte(0x87)
VOCAB = b'\x87'
# newbanana tokens
OPEN = six.int2byte(0x88)
CLOSE = six.int2byte(0x89)
ABORT = six.int2byte(0x8A)
ERROR = six.int2byte(0x8D)
PING = six.int2byte(0x8E)
PONG = six.int2byte(0x8F)
OPEN = b'\x88'
CLOSE = b'\x89'
ABORT = b'\x8A'
ERROR = b'\x8D'
PING = b'\x8E'
PONG = b'\x8F'

tokenNames = {
LIST: "LIST",