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

Got rid of six. #412

Merged
merged 1 commit into from
Nov 23, 2022
Merged
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
14 changes: 2 additions & 12 deletions pgpy/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

from pyasn1.type.univ import ObjectIdentifier

import six

from cryptography.hazmat.backends import openssl
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.ciphers import algorithms
Expand Down Expand Up @@ -63,13 +61,8 @@ def __rand__(self, other): # pragma: no cover
return self & other


if six.PY2:
class FlagEnum(IntEnum):
__metaclass__ = FlagEnumMeta

else:
namespace = FlagEnumMeta.__prepare__('FlagEnum', (IntEnum,))
FlagEnum = FlagEnumMeta('FlagEnum', (IntEnum,), namespace)
namespace = FlagEnumMeta.__prepare__('FlagEnum', (IntEnum,))
FlagEnum = FlagEnumMeta('FlagEnum', (IntEnum,), namespace)



Expand Down Expand Up @@ -336,9 +329,6 @@ def compress(self, data):
raise NotImplementedError(self)

def decompress(self, data):
if six.PY2:
data = bytes(data)

if self is CompressionAlgorithm.Uncompressed:
return data

Expand Down
4 changes: 1 addition & 3 deletions pgpy/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
import contextlib
import functools
import six
import logging

try:
Expand Down Expand Up @@ -116,8 +115,7 @@ def check_attributes(self, key):
"".format(attr=attr, eval=str(expected), got=str(getattr(key, attr))))

def __call__(self, action):
# @functools.wraps(action)
@six.wraps(action)
@functools.wraps(action)
def _action(key, *args, **kwargs):
if key._key is None:
raise PGPError("No key!")
Expand Down
128 changes: 0 additions & 128 deletions pgpy/memoryview.py

This file was deleted.

6 changes: 2 additions & 4 deletions pgpy/packet/packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

from datetime import datetime, timezone

import six

from cryptography.hazmat.primitives import constant_time
from cryptography.hazmat.primitives.asymmetric import padding

Expand Down Expand Up @@ -697,7 +695,7 @@ def signer(self):
return self._signer

@signer.register(str)
@signer.register(six.text_type)
@signer.register(str)
def signer_str(self, val):
self._signer = val

Expand All @@ -719,7 +717,7 @@ def __bytearray__(self):
_bytes += bytearray([self.sigtype])
_bytes += bytearray([self.halg])
_bytes += bytearray([self.pubalg])
_bytes += binascii.unhexlify(six.b(self.signer))
_bytes += binascii.unhexlify(self.signer.encode("latin-1"))
_bytes += bytearray([int(self.nested)])
return _bytes

Expand Down
20 changes: 9 additions & 11 deletions pgpy/packet/subpackets/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from datetime import timedelta
from datetime import timezone

import six

from .types import EmbeddedSignatureHeader
from .types import Signature

Expand Down Expand Up @@ -69,7 +67,7 @@ def uri(self):
return self._uri

@uri.register(str)
@uri.register(six.text_type)
@uri.register(str)
def uri_str(self, val):
self._uri = val

Expand Down Expand Up @@ -420,7 +418,7 @@ def regex(self):
return self._regex

@regex.register(str)
@regex.register(six.text_type)
@regex.register(str)
def regex_str(self, val):
self._regex = val

Expand Down Expand Up @@ -550,7 +548,7 @@ def fingerprint(self):
return self._fingerprint

@fingerprint.register(str)
@fingerprint.register(six.text_type)
@fingerprint.register(str)
@fingerprint.register(Fingerprint)
def fingerprint_str(self, val):
self._fingerprint = Fingerprint(val)
Expand Down Expand Up @@ -633,7 +631,7 @@ def name(self):
return self._name

@name.register(str)
@name.register(six.text_type)
@name.register(str)
def name_str(self, val):
self._name = val

Expand All @@ -646,7 +644,7 @@ def value(self):
return self._value

@value.register(str)
@value.register(six.text_type)
@value.register(str)
def value_str(self, val):
self._value = val

Expand Down Expand Up @@ -761,7 +759,7 @@ def userid(self):
return self._userid

@userid.register(str)
@userid.register(six.text_type)
@userid.register(str)
def userid_str(self, val):
self._userid = val

Expand Down Expand Up @@ -805,7 +803,7 @@ def string(self):
return self._string

@string.register(str)
@string.register(six.text_type)
@string.register(str)
def string_str(self, val):
self._string = val

Expand Down Expand Up @@ -932,7 +930,7 @@ def issuer_fingerprint(self):
return self._issuer_fpr

@issuer_fingerprint.register(str)
@issuer_fingerprint.register(six.text_type)
@issuer_fingerprint.register(str)
@issuer_fingerprint.register(Fingerprint)
def issuer_fingerprint_str(self, val):
self._issuer_fpr = Fingerprint(val)
Expand Down Expand Up @@ -1004,7 +1002,7 @@ def intended_recipient(self):
return self._intended_recipient

@intended_recipient.register(str)
@intended_recipient.register(six.text_type)
@intended_recipient.register(str)
@intended_recipient.register(Fingerprint)
def intended_recipient_str(self, val):
self._intended_recipient = Fingerprint(val)
Expand Down
3 changes: 0 additions & 3 deletions pgpy/packet/subpackets/userattribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

from ...decorators import sdproperty

from ...memoryview import memoryview


__all__ = ('Image',)

Expand Down Expand Up @@ -100,7 +98,6 @@ def __bytearray__(self):
def parse(self, packet):
super(Image, self).parse(packet)

# on Python 2, this will be the wrapper object from memoryview.py
with memoryview(packet) as _head:
_, self.version, self.iencoding, _, _, _ = struct.unpack_from('<hbbiii', _head[:16].tobytes())
del packet[:16]
Expand Down
9 changes: 3 additions & 6 deletions pgpy/packet/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import abc
import copy

import six

from ..constants import PacketTag

from ..decorators import sdproperty
Expand Down Expand Up @@ -149,7 +147,7 @@ class Packet(Dispatchable):
def __init__(self, _=None):
super(Packet, self).__init__()
self.header = self.__headercls__()
if isinstance(self.__typeid__, six.integer_types):
if isinstance(self.__typeid__, int):
self.header.tag = self.__typeid__

@abc.abstractmethod
Expand All @@ -176,7 +174,7 @@ class VersionedPacket(Packet):

def __init__(self):
super(VersionedPacket, self).__init__()
if isinstance(self.__ver__, six.integer_types):
if isinstance(self.__ver__, int):
self.header.version = self.__ver__

def __repr__(self):
Expand Down Expand Up @@ -237,8 +235,7 @@ class Sub(Key):


# This is required for class MPI to work in both Python 2 and 3
if not six.PY2:
long = int
long = int


class MPI(long):
Expand Down
Loading