summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2020-10-06 21:38:05 -0400
committerEli Collins <elic@assurancetechnologies.com>2020-10-06 21:38:05 -0400
commit1841864071b4de404c74d6c1187b7752cd57691d (patch)
treee0c98faf542307d4a06ec9798e00e05fc007daa1
parent73ab1733ebe4813063ecf96ba9fca028392db7ff (diff)
downloadpasslib-1841864071b4de404c74d6c1187b7752cd57691d.tar.gz
python compat cleanup -- use magic super() calls
-rw-r--r--passlib/apache.py4
-rw-r--r--passlib/context.py2
-rw-r--r--passlib/ext/django/utils.py6
-rw-r--r--passlib/handlers/argon2.py8
-rw-r--r--passlib/handlers/bcrypt.py24
-rw-r--r--passlib/handlers/cisco.py4
-rw-r--r--passlib/handlers/des_crypt.py8
-rw-r--r--passlib/handlers/django.py6
-rw-r--r--passlib/handlers/fshp.py4
-rw-r--r--passlib/handlers/misc.py2
-rw-r--r--passlib/handlers/scram.py6
-rw-r--r--passlib/handlers/scrypt.py8
-rw-r--r--passlib/handlers/sha2_crypt.py2
-rw-r--r--passlib/handlers/sun_md5_crypt.py2
-rw-r--r--passlib/pwd.py8
-rw-r--r--passlib/tests/test_context.py2
-rw-r--r--passlib/tests/test_crypto_builtin_md4.py4
-rw-r--r--passlib/tests/test_crypto_scrypt.py4
-rw-r--r--passlib/tests/test_ext_django.py4
-rw-r--r--passlib/tests/test_ext_django_source.py2
-rw-r--r--passlib/tests/test_handlers.py6
-rw-r--r--passlib/tests/test_handlers_argon2.py4
-rw-r--r--passlib/tests/test_handlers_bcrypt.py8
-rw-r--r--passlib/tests/test_handlers_django.py6
-rw-r--r--passlib/tests/test_handlers_pbkdf2.py2
-rw-r--r--passlib/tests/test_handlers_scrypt.py4
-rw-r--r--passlib/tests/test_pwd.py2
-rw-r--r--passlib/tests/test_registry.py2
-rw-r--r--passlib/tests/test_totp.py2
-rw-r--r--passlib/tests/test_utils_handlers.py2
-rw-r--r--passlib/tests/test_utils_md4.py2
-rw-r--r--passlib/tests/test_utils_pbkdf2.py4
-rw-r--r--passlib/tests/utils.py25
-rw-r--r--passlib/totp.py2
-rw-r--r--passlib/utils/binary.py2
-rw-r--r--passlib/utils/handlers.py44
36 files changed, 113 insertions, 114 deletions
diff --git a/passlib/apache.py b/passlib/apache.py
index 8373c67..80a8a91 100644
--- a/passlib/apache.py
+++ b/passlib/apache.py
@@ -679,7 +679,7 @@ class HtpasswdFile(_CommonFile):
default_scheme = htpasswd_defaults.get(default_scheme, default_scheme)
context = context.copy(default=default_scheme)
self.context = context
- super(HtpasswdFile, self).__init__(path, **kwds)
+ super().__init__(path, **kwds)
def _parse_record(self, record, lineno):
# NOTE: should return (user, hash) tuple
@@ -953,7 +953,7 @@ class HtdigestFile(_CommonFile):
#===================================================================
def __init__(self, path=None, default_realm=None, **kwds):
self.default_realm = default_realm
- super(HtdigestFile, self).__init__(path, **kwds)
+ super().__init__(path, **kwds)
def _parse_record(self, record, lineno):
result = record.rstrip().split(_BCOLON)
diff --git a/passlib/context.py b/passlib/context.py
index 7fabc77..f210a1f 100644
--- a/passlib/context.py
+++ b/passlib/context.py
@@ -1981,7 +1981,7 @@ class LazyCryptContext(CryptContext):
onload = kwds.pop("onload")
kwds = onload(**kwds)
del self._lazy_kwds
- super(LazyCryptContext, self).__init__(**kwds)
+ super().__init__(**kwds)
self.__class__ = CryptContext
def __getattribute__(self, attr):
diff --git a/passlib/ext/django/utils.py b/passlib/ext/django/utils.py
index ab508a3..001df4e 100644
--- a/passlib/ext/django/utils.py
+++ b/passlib/ext/django/utils.py
@@ -165,7 +165,7 @@ class DjangoTranslator(object):
#=============================================================================
def __init__(self, context=None, **kwds):
- super(DjangoTranslator, self).__init__(**kwds)
+ super().__init__(**kwds)
if context is not None:
self.context = context
@@ -440,7 +440,7 @@ class DjangoContextAdapter(DjangoTranslator):
# init parent, filling in default context object
if context is None:
context = CryptContext()
- super(DjangoContextAdapter, self).__init__(context=context, **kwds)
+ super().__init__(context=context, **kwds)
# setup user category
if get_user_category:
@@ -477,7 +477,7 @@ class DjangoContextAdapter(DjangoTranslator):
reset_hashers(setting="PASSWORD_HASHERS")
# reset internal caches
- super(DjangoContextAdapter, self).reset_hashers()
+ super().reset_hashers()
#=============================================================================
# django hashers helpers -- hasher lookup
diff --git a/passlib/handlers/argon2.py b/passlib/handlers/argon2.py
index 5935c3e..f0c2881 100644
--- a/passlib/handlers/argon2.py
+++ b/passlib/handlers/argon2.py
@@ -283,7 +283,7 @@ class _Argon2Common(uh.SubclassBackendMixin, uh.ParallelismMixin,
digest_size = checksum_size
# create variant
- subcls = super(_Argon2Common, cls).using(**kwds)
+ subcls = super().using(**kwds)
# set type
if type is not None:
@@ -462,7 +462,7 @@ class _Argon2Common(uh.SubclassBackendMixin, uh.ParallelismMixin,
self.checksum_size = len(checksum)
# call parent
- super(_Argon2Common, self).__init__(**kwds)
+ super().__init__(**kwds)
# init type
if type is None:
@@ -574,7 +574,7 @@ class _Argon2Common(uh.SubclassBackendMixin, uh.ParallelismMixin,
return True
if self.checksum_size != cls.checksum_size:
return True
- return super(_Argon2Common, self)._calc_needs_update(**kwds)
+ return super()._calc_needs_update(**kwds)
#===================================================================
# backend loading
@@ -680,7 +680,7 @@ class _NoBackend(_Argon2Common):
self._stub_requires_backend()
# NOTE: have to use super() here so that we don't recursively
# call subclass's wrapped _calc_checksum
- return super(argon2, self)._calc_checksum(secret)
+ return super()._calc_checksum(secret)
#===================================================================
# eoc
diff --git a/passlib/handlers/bcrypt.py b/passlib/handlers/bcrypt.py
index 7a57d47..9a10f9e 100644
--- a/passlib/handlers/bcrypt.py
+++ b/passlib/handlers/bcrypt.py
@@ -206,7 +206,7 @@ class _BcryptCommon(uh.SubclassBackendMixin, uh.TruncateMixin, uh.HasManyIdents,
# TODO: try to detect incorrect 8bit/wraparound hashes using kwds.get("secret")
# hand off to base implementation, so HasRounds can check rounds value.
- return super(_BcryptCommon, cls).needs_update(hash, **kwds)
+ return super().needs_update(hash, **kwds)
#===================================================================
# specialized salt generation - fixes passlib issue 25
@@ -224,12 +224,12 @@ class _BcryptCommon(uh.SubclassBackendMixin, uh.TruncateMixin, uh.HasManyIdents,
def _generate_salt(cls):
# generate random salt as normal,
# but repair last char so the padding bits always decode to zero.
- salt = super(_BcryptCommon, cls)._generate_salt()
+ salt = super()._generate_salt()
return bcrypt64.repair_unused(salt)
@classmethod
def _norm_salt(cls, salt, **kwds):
- salt = super(_BcryptCommon, cls)._norm_salt(salt, **kwds)
+ salt = super()._norm_salt(salt, **kwds)
assert salt is not None, "HasSalt didn't generate new salt!"
changed, salt = bcrypt64.check_repair_unused(salt)
if changed:
@@ -243,7 +243,7 @@ class _BcryptCommon(uh.SubclassBackendMixin, uh.TruncateMixin, uh.HasManyIdents,
return salt
def _norm_checksum(self, checksum, relaxed=False):
- checksum = super(_BcryptCommon, self)._norm_checksum(checksum, relaxed=relaxed)
+ checksum = super()._norm_checksum(checksum, relaxed=relaxed)
changed, checksum = bcrypt64.check_repair_unused(checksum)
if changed:
warn(
@@ -583,7 +583,7 @@ class _NoBackend(_BcryptCommon):
self._stub_requires_backend()
# NOTE: have to use super() here so that we don't recursively
# call subclass's wrapped _calc_checksum, e.g. bcrypt_sha256._calc_checksum
- return super(bcrypt, self)._calc_checksum(secret)
+ return super()._calc_checksum(secret)
#===================================================================
# eoc
@@ -866,17 +866,17 @@ class _wrapped_bcrypt(bcrypt):
# def hash(cls, secret, **kwds):
# # bypass bcrypt backend overriding this method
# # XXX: would wrapping bcrypt make this easier than subclassing it?
- # return super(_BcryptCommon, cls).hash(secret, **kwds)
+ # return super().hash(secret, **kwds)
#
# @classmethod
# def verify(cls, secret, hash):
# # bypass bcrypt backend overriding this method
- # return super(_BcryptCommon, cls).verify(secret, hash)
+ # return super().verify(secret, hash)
#
# @classmethod
# def genhash(cls, secret, hash):
# # bypass bcrypt backend overriding this method
- # return super(_BcryptCommon, cls).genhash(secret, hash)
+ # return super().genhash(secret, hash)
@classmethod
def _check_truncate_policy(cls, secret):
@@ -950,7 +950,7 @@ class bcrypt_sha256(_wrapped_bcrypt):
@classmethod
def using(cls, version=None, **kwds):
- subcls = super(bcrypt_sha256, cls).using(**kwds)
+ subcls = super().using(**kwds)
if version is not None:
subcls.version = subcls._norm_version(version)
ident = subcls.default_ident
@@ -1053,7 +1053,7 @@ class bcrypt_sha256(_wrapped_bcrypt):
def __init__(self, version=None, **kwds):
if version is not None:
self.version = self._norm_version(version)
- super(bcrypt_sha256, self).__init__(**kwds)
+ super().__init__(**kwds)
#===================================================================
# version
@@ -1106,7 +1106,7 @@ class bcrypt_sha256(_wrapped_bcrypt):
key = b64encode(digest)
# hand result off to normal bcrypt algorithm
- return super(bcrypt_sha256, self)._calc_checksum(key)
+ return super()._calc_checksum(key)
#===================================================================
# other
@@ -1115,7 +1115,7 @@ class bcrypt_sha256(_wrapped_bcrypt):
def _calc_needs_update(self, **kwds):
if self.version < type(self).version:
return True
- return super(bcrypt_sha256, self)._calc_needs_update(**kwds)
+ return super()._calc_needs_update(**kwds)
#===================================================================
# eoc
diff --git a/passlib/handlers/cisco.py b/passlib/handlers/cisco.py
index 09141c8..1b242e9 100644
--- a/passlib/handlers/cisco.py
+++ b/passlib/handlers/cisco.py
@@ -350,7 +350,7 @@ class cisco_type7(uh.GenericHandler):
#===================================================================
@classmethod
def using(cls, salt=None, **kwds):
- subcls = super(cisco_type7, cls).using(**kwds)
+ subcls = super().using(**kwds)
if salt is not None:
salt = subcls._norm_salt(salt, relaxed=kwds.get("relaxed"))
subcls._generate_salt = staticmethod(lambda: salt)
@@ -365,7 +365,7 @@ class cisco_type7(uh.GenericHandler):
return cls(salt=salt, checksum=hash[2:].upper())
def __init__(self, salt=None, **kwds):
- super(cisco_type7, self).__init__(**kwds)
+ super().__init__(**kwds)
if salt is not None:
salt = self._norm_salt(salt)
elif self.use_defaults:
diff --git a/passlib/handlers/des_crypt.py b/passlib/handlers/des_crypt.py
index 2f90e72..58707ee 100644
--- a/passlib/handlers/des_crypt.py
+++ b/passlib/handlers/des_crypt.py
@@ -332,7 +332,7 @@ class bsdi_crypt(uh.HasManyBackends, uh.HasRounds, uh.HasSalt, uh.GenericHandler
@classmethod
def using(cls, **kwds):
- subcls = super(bsdi_crypt, cls).using(**kwds)
+ subcls = super().using(**kwds)
if not subcls.default_rounds & 1:
# issue warning if caller set an even 'rounds' value.
warn("bsdi_crypt rounds should be odd, as even rounds may reveal weak DES keys",
@@ -341,7 +341,7 @@ class bsdi_crypt(uh.HasManyBackends, uh.HasRounds, uh.HasSalt, uh.GenericHandler
@classmethod
def _generate_rounds(cls):
- rounds = super(bsdi_crypt, cls)._generate_rounds()
+ rounds = super()._generate_rounds()
# ensure autogenerated rounds are always odd
# NOTE: doing this even for default_rounds so needs_update() doesn't get
# caught in a loop.
@@ -358,7 +358,7 @@ class bsdi_crypt(uh.HasManyBackends, uh.HasRounds, uh.HasSalt, uh.GenericHandler
if not self.rounds & 1:
return True
# hand off to base implementation
- return super(bsdi_crypt, self)._calc_needs_update(**kwds)
+ return super()._calc_needs_update(**kwds)
#===================================================================
# backends
@@ -461,7 +461,7 @@ class bigcrypt(uh.HasSalt, uh.GenericHandler):
return hash
def _norm_checksum(self, checksum, relaxed=False):
- checksum = super(bigcrypt, self)._norm_checksum(checksum, relaxed=relaxed)
+ checksum = super()._norm_checksum(checksum, relaxed=relaxed)
if len(checksum) % 11:
raise uh.exc.InvalidHashError(self)
return checksum
diff --git a/passlib/handlers/django.py b/passlib/handlers/django.py
index 95d1a13..aabd998 100644
--- a/passlib/handlers/django.py
+++ b/passlib/handlers/django.py
@@ -225,17 +225,17 @@ class django_bcrypt_sha256(_wrapped_bcrypt):
bhash = hash[len(cls.django_prefix):]
if not bhash.startswith("$2"):
raise uh.exc.MalformedHashError(cls)
- return super(django_bcrypt_sha256, cls).from_string(bhash)
+ return super().from_string(bhash)
def to_string(self):
- bhash = super(django_bcrypt_sha256, self).to_string()
+ bhash = super().to_string()
return self.django_prefix + bhash
def _calc_checksum(self, secret):
if isinstance(secret, str):
secret = secret.encode("utf-8")
secret = hexlify(self._digest(secret).digest())
- return super(django_bcrypt_sha256, self)._calc_checksum(secret)
+ return super()._calc_checksum(secret)
#=============================================================================
# PBKDF2 variants
diff --git a/passlib/handlers/fshp.py b/passlib/handlers/fshp.py
index 5a28b29..f8f31a9 100644
--- a/passlib/handlers/fshp.py
+++ b/passlib/handlers/fshp.py
@@ -100,7 +100,7 @@ class fshp(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
#===================================================================
@classmethod
def using(cls, variant=None, **kwds):
- subcls = super(fshp, cls).using(**kwds)
+ subcls = super().using(**kwds)
if variant is not None:
subcls.default_variant = cls._norm_variant(variant)
return subcls
@@ -124,7 +124,7 @@ class fshp(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
else:
raise TypeError("no variant specified")
self.variant = variant
- super(fshp, self).__init__(**kwds)
+ super().__init__(**kwds)
@classmethod
def _norm_variant(cls, variant):
diff --git a/passlib/handlers/misc.py b/passlib/handlers/misc.py
index 58366ba..8c4de54 100644
--- a/passlib/handlers/misc.py
+++ b/passlib/handlers/misc.py
@@ -65,7 +65,7 @@ class unix_disabled(uh.ifc.DisabledHash, uh.MinimalHandler):
@classmethod
def using(cls, marker=None, **kwds):
- subcls = super(unix_disabled, cls).using(**kwds)
+ subcls = super().using(**kwds)
if marker is not None:
if not cls.identify(marker):
raise ValueError("invalid marker: %r" % marker)
diff --git a/passlib/handlers/scram.py b/passlib/handlers/scram.py
index eac9c24..256de03 100644
--- a/passlib/handlers/scram.py
+++ b/passlib/handlers/scram.py
@@ -286,7 +286,7 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
default_algs = algs
# create subclass
- subcls = super(scram, cls).using(**kwds)
+ subcls = super().using(**kwds)
# fill in algs
if default_algs is not None:
@@ -297,7 +297,7 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
# init
#===================================================================
def __init__(self, algs=None, **kwds):
- super(scram, self).__init__(**kwds)
+ super().__init__(**kwds)
# init algs
digest_map = self.checksum
@@ -357,7 +357,7 @@ class scram(uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum, uh.GenericHandler):
return True
# hand off to base implementation
- return super(scram, self)._calc_needs_update(**kwds)
+ return super()._calc_needs_update(**kwds)
#===================================================================
# digest methods
diff --git a/passlib/handlers/scrypt.py b/passlib/handlers/scrypt.py
index f6131f5..2d3d36b 100644
--- a/passlib/handlers/scrypt.py
+++ b/passlib/handlers/scrypt.py
@@ -153,7 +153,7 @@ class scrypt(uh.ParallelismMixin, uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum
@classmethod
def using(cls, block_size=None, **kwds):
- subcls = super(scrypt, cls).using(**kwds)
+ subcls = super().using(**kwds)
if block_size is not None:
if isinstance(block_size, str):
block_size = int(block_size)
@@ -302,7 +302,7 @@ class scrypt(uh.ParallelismMixin, uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum
# init
#===================================================================
def __init__(self, block_size=None, **kwds):
- super(scrypt, self).__init__(**kwds)
+ super().__init__(**kwds)
# init block size
if block_size is None:
@@ -319,7 +319,7 @@ class scrypt(uh.ParallelismMixin, uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum
return uh.norm_integer(cls, block_size, min=1, param="block_size", relaxed=relaxed)
def _generate_salt(self):
- salt = super(scrypt, self)._generate_salt()
+ salt = super()._generate_salt()
if self.ident == IDENT_7:
# this format doesn't support non-ascii salts.
# as workaround, we take raw bytes, encoded to base64
@@ -371,7 +371,7 @@ class scrypt(uh.ParallelismMixin, uh.HasRounds, uh.HasRawSalt, uh.HasRawChecksum
# XXX: for now, marking all hashes which don't have matching block_size setting
if self.block_size != type(self).block_size:
return True
- return super(scrypt, self)._calc_needs_update(**kwds)
+ return super()._calc_needs_update(**kwds)
#===================================================================
# eoc
diff --git a/passlib/handlers/sha2_crypt.py b/passlib/handlers/sha2_crypt.py
index d5b89a3..d539472 100644
--- a/passlib/handlers/sha2_crypt.py
+++ b/passlib/handlers/sha2_crypt.py
@@ -276,7 +276,7 @@ class _SHA2_Common(uh.HasManyBackends, uh.HasRounds, uh.HasSalt,
implicit_rounds = False
def __init__(self, implicit_rounds=None, **kwds):
- super(_SHA2_Common, self).__init__(**kwds)
+ super().__init__(**kwds)
# if user calls hash() w/ 5000 rounds, default to compact form.
if implicit_rounds is None:
implicit_rounds = (self.use_defaults and self.rounds == 5000)
diff --git a/passlib/handlers/sun_md5_crypt.py b/passlib/handlers/sun_md5_crypt.py
index b472c2e..d80d7ff 100644
--- a/passlib/handlers/sun_md5_crypt.py
+++ b/passlib/handlers/sun_md5_crypt.py
@@ -248,7 +248,7 @@ class sun_md5_crypt(uh.HasRounds, uh.HasSalt, uh.GenericHandler):
#===================================================================
def __init__(self, bare_salt=False, **kwds):
self.bare_salt = bare_salt
- super(sun_md5_crypt, self).__init__(**kwds)
+ super().__init__(**kwds)
#===================================================================
# internal helpers
diff --git a/passlib/pwd.py b/passlib/pwd.py
index 847b90b..6c7f1a4 100644
--- a/passlib/pwd.py
+++ b/passlib/pwd.py
@@ -265,7 +265,7 @@ class SequenceGenerator(object):
# hand off to parent
if kwds and _superclasses(self, SequenceGenerator) == (object,):
raise TypeError("Unexpected keyword(s): %s" % ", ".join(kwds.keys()))
- super(SequenceGenerator, self).__init__(**kwds)
+ super().__init__(**kwds)
#=============================================================================
# informational helpers
@@ -390,7 +390,7 @@ class WordGenerator(SequenceGenerator):
self.chars = chars
# hand off to parent
- super(WordGenerator, self).__init__(**kwds)
+ super().__init__(**kwds)
# log.debug("WordGenerator(): entropy/char=%r", self.entropy_per_symbol)
#=============================================================================
@@ -543,7 +543,7 @@ class WordsetDict(MutableMapping):
def __init__(self, *args, **kwds):
self.paths = {}
self._loaded = {}
- super(WordsetDict, self).__init__(*args, **kwds)
+ super().__init__(*args, **kwds)
def __getitem__(self, key):
try:
@@ -655,7 +655,7 @@ class PhraseGenerator(SequenceGenerator):
self.sep = sep
# hand off to parent
- super(PhraseGenerator, self).__init__(**kwds)
+ super().__init__(**kwds)
##log.debug("PhraseGenerator(): entropy/word=%r entropy/char=%r min_chars=%r",
## self.entropy_per_symbol, self.entropy_per_char, self.min_chars)
diff --git a/passlib/tests/test_context.py b/passlib/tests/test_context.py
index 8bb4e3e..ea11f4e 100644
--- a/passlib/tests/test_context.py
+++ b/passlib/tests/test_context.py
@@ -170,7 +170,7 @@ sha512_crypt__min_rounds = 45000
# setup
#===================================================================
def setUp(self):
- super(CryptContextTest, self).setUp()
+ super().setUp()
warnings.filterwarnings("ignore", "The 'all' scheme is deprecated.*")
warnings.filterwarnings("ignore", ".*'scheme' keyword is deprecated as of Passlib 1.7.*")
diff --git a/passlib/tests/test_crypto_builtin_md4.py b/passlib/tests/test_crypto_builtin_md4.py
index 4f5b798..e74b924 100644
--- a/passlib/tests/test_crypto_builtin_md4.py
+++ b/passlib/tests/test_crypto_builtin_md4.py
@@ -118,7 +118,7 @@ class MD4_SSL_Test(_Common_MD4_Test):
# this is more to test our test is correct :)
def setUp(self):
- super(MD4_SSL_Test, self).setUp()
+ super().setUp()
# make sure we're using right constructor.
self.assertEqual(self.get_md4_const().__module__, "hashlib")
@@ -128,7 +128,7 @@ class MD4_Builtin_Test(_Common_MD4_Test):
descriptionPrefix = "passlib.crypto._md4.md4()"
def setUp(self):
- super(MD4_Builtin_Test, self).setUp()
+ super().setUp()
if has_native_md4():
diff --git a/passlib/tests/test_crypto_scrypt.py b/passlib/tests/test_crypto_scrypt.py
index 04efdd9..5009db0 100644
--- a/passlib/tests/test_crypto_scrypt.py
+++ b/passlib/tests/test_crypto_scrypt.py
@@ -313,7 +313,7 @@ class _CommonScryptTest(TestCase):
def setUp(self):
assert self.backend
scrypt_mod._set_backend(self.backend)
- super(_CommonScryptTest, self).setUp()
+ super().setUp()
#=============================================================================
# reference vectors
@@ -598,7 +598,7 @@ class BuiltinScryptTest(_CommonScryptTest):
backend = "builtin"
def setUp(self):
- super(BuiltinScryptTest, self).setUp()
+ super().setUp()
warnings.filterwarnings("ignore", "(?i)using builtin scrypt backend",
category=exc.PasslibSecurityWarning)
diff --git a/passlib/tests/test_ext_django.py b/passlib/tests/test_ext_django.py
index 2260d66..b43afea 100644
--- a/passlib/tests/test_ext_django.py
+++ b/passlib/tests/test_ext_django.py
@@ -281,7 +281,7 @@ class _ExtensionSupport(object):
class _ExtensionTest(TestCase, _ExtensionSupport):
def setUp(self):
- super(_ExtensionTest, self).setUp()
+ super().setUp()
self.require_TEST_MODE("default")
@@ -627,7 +627,7 @@ class ExtensionBehaviorTest(DjangoBehaviorTest):
)
def setUp(self):
- super(ExtensionBehaviorTest, self).setUp()
+ super().setUp()
self.load_extension(PASSLIB_CONFIG=self.config)
class DjangoExtensionTest(_ExtensionTest):
diff --git a/passlib/tests/test_ext_django_source.py b/passlib/tests/test_ext_django_source.py
index cc8c25f..a6da6b6 100644
--- a/passlib/tests/test_ext_django_source.py
+++ b/passlib/tests/test_ext_django_source.py
@@ -207,7 +207,7 @@ if test_hashers_mod:
def tearDown(self):
# NOTE: could rely on addCleanup() instead, but need py26 compat
self.unload_extension()
- super(HashersTest, self).tearDown()
+ super().tearDown()
#==================================================================
# skip a few methods that can't be replicated properly
diff --git a/passlib/tests/test_handlers.py b/passlib/tests/test_handlers.py
index 14623e1..e3a3e30 100644
--- a/passlib/tests/test_handlers.py
+++ b/passlib/tests/test_handlers.py
@@ -205,7 +205,7 @@ class _bsdi_crypt_test(HandlerCase):
def test_77_fuzz_input(self, **kwds):
# we want to generate even rounds to verify it's correct, but want to ignore warnings
warnings.filterwarnings("ignore", "bsdi_crypt rounds should be odd.*")
- super(_bsdi_crypt_test, self).test_77_fuzz_input(**kwds)
+ super().test_77_fuzz_input(**kwds)
def test_needs_update_w_even_rounds(self):
"""needs_update() should flag even rounds"""
@@ -703,7 +703,7 @@ class _ldap_sha1_crypt_test(HandlerCase):
def populate_settings(self, kwds):
kwds.setdefault("rounds", 10)
- super(_ldap_sha1_crypt_test, self).populate_settings(kwds)
+ super().populate_settings(kwds)
def test_77_fuzz_input(self, **ignored):
raise self.skipTest("unneeded")
@@ -1751,7 +1751,7 @@ class unix_disabled_test(HandlerCase):
def test_76_hash_border(self):
# so empty strings pass
self.accepts_all_hashes = True
- super(unix_disabled_test, self).test_76_hash_border()
+ super().test_76_hash_border()
def test_90_special(self):
"""test marker option & special behavior"""
diff --git a/passlib/tests/test_handlers_argon2.py b/passlib/tests/test_handlers_argon2.py
index a5309d2..3f800ba 100644
--- a/passlib/tests/test_handlers_argon2.py
+++ b/passlib/tests/test_handlers_argon2.py
@@ -199,7 +199,7 @@ class _base_argon2_test(HandlerCase):
]
def setUpWarnings(self):
- super(_base_argon2_test, self).setUpWarnings()
+ super().setUpWarnings()
warnings.filterwarnings("ignore", ".*Using argon2pure backend.*")
def do_stub_encrypt(self, handler=None, **settings):
@@ -212,7 +212,7 @@ class _base_argon2_test(HandlerCase):
assert self.checksum
return self.to_string()
else:
- return super(_base_argon2_test, self).do_stub_encrypt(handler, **settings)
+ return super().do_stub_encrypt(handler, **settings)
def test_03_legacy_hash_workflow(self):
# override base method
diff --git a/passlib/tests/test_handlers_bcrypt.py b/passlib/tests/test_handlers_bcrypt.py
index 683b9ba..abe44ec 100644
--- a/passlib/tests/test_handlers_bcrypt.py
+++ b/passlib/tests/test_handlers_bcrypt.py
@@ -177,7 +177,7 @@ class _bcrypt_test(HandlerCase):
self.addCleanup(os.environ.__delitem__, key)
os.environ[key] = "true"
- super(_bcrypt_test, self).setUp()
+ super().setUp()
# silence this warning, will come up a bunch during testing of old 2a hashes.
warnings.filterwarnings("ignore", ".*backend is vulnerable to the bsd wraparound bug.*")
@@ -186,7 +186,7 @@ class _bcrypt_test(HandlerCase):
# builtin is still just way too slow.
if self.backend == "builtin":
kwds.setdefault("rounds", 4)
- super(_bcrypt_test, self).populate_settings(kwds)
+ super().populate_settings(kwds)
#===================================================================
# fuzz testing
@@ -523,14 +523,14 @@ class _bcrypt_sha256_test(HandlerCase):
else:
self.addCleanup(os.environ.__delitem__, key)
os.environ[key] = "enabled"
- super(_bcrypt_sha256_test, self).setUp()
+ super().setUp()
warnings.filterwarnings("ignore", ".*backend is vulnerable to the bsd wraparound bug.*")
def populate_settings(self, kwds):
# builtin is still just way too slow.
if self.backend == "builtin":
kwds.setdefault("rounds", 4)
- super(_bcrypt_sha256_test, self).populate_settings(kwds)
+ super().populate_settings(kwds)
#===================================================================
# override ident tests for now
diff --git a/passlib/tests/test_handlers_django.py b/passlib/tests/test_handlers_django.py
index d5ed9c6..9d03a98 100644
--- a/passlib/tests/test_handlers_django.py
+++ b/passlib/tests/test_handlers_django.py
@@ -297,7 +297,7 @@ class django_bcrypt_test(HandlerCase, _DjangoHelper):
def populate_settings(self, kwds):
# speed up test w/ lower rounds
kwds.setdefault("rounds", 4)
- super(django_bcrypt_test, self).populate_settings(kwds)
+ super().populate_settings(kwds)
class FuzzHashGenerator(HandlerCase.FuzzHashGenerator):
@@ -347,7 +347,7 @@ class django_bcrypt_sha256_test(HandlerCase, _DjangoHelper):
def populate_settings(self, kwds):
# speed up test w/ lower rounds
kwds.setdefault("rounds", 4)
- super(django_bcrypt_sha256_test, self).populate_settings(kwds)
+ super().populate_settings(kwds)
class FuzzHashGenerator(HandlerCase.FuzzHashGenerator):
@@ -381,7 +381,7 @@ class django_argon2_test(HandlerCase, _DjangoHelper):
]
def setUpWarnings(self):
- super(django_argon2_test, self).setUpWarnings()
+ super().setUpWarnings()
warnings.filterwarnings("ignore", ".*Using argon2pure backend.*")
def do_stub_encrypt(self, handler=None, **settings):
diff --git a/passlib/tests/test_handlers_pbkdf2.py b/passlib/tests/test_handlers_pbkdf2.py
index e1fa0c9..658f2ce 100644
--- a/passlib/tests/test_handlers_pbkdf2.py
+++ b/passlib/tests/test_handlers_pbkdf2.py
@@ -244,7 +244,7 @@ class scram_test(HandlerCase):
]
def setUp(self):
- super(scram_test, self).setUp()
+ super().setUp()
# some platforms lack stringprep (e.g. Jython, IronPython)
self.require_stringprep()
diff --git a/passlib/tests/test_handlers_scrypt.py b/passlib/tests/test_handlers_scrypt.py
index 5ab6d9f..2ce6463 100644
--- a/passlib/tests/test_handlers_scrypt.py
+++ b/passlib/tests/test_handlers_scrypt.py
@@ -86,14 +86,14 @@ class _scrypt_test(HandlerCase):
]
def setUpWarnings(self):
- super(_scrypt_test, self).setUpWarnings()
+ super().setUpWarnings()
warnings.filterwarnings("ignore", ".*using builtin scrypt backend.*")
def populate_settings(self, kwds):
# builtin is still just way too slow.
if self.backend == "builtin":
kwds.setdefault("rounds", 6)
- super(_scrypt_test, self).populate_settings(kwds)
+ super().populate_settings(kwds)
class FuzzHashGenerator(HandlerCase.FuzzHashGenerator):
diff --git a/passlib/tests/test_pwd.py b/passlib/tests/test_pwd.py
index 2c983cd..cc7bad3 100644
--- a/passlib/tests/test_pwd.py
+++ b/passlib/tests/test_pwd.py
@@ -66,7 +66,7 @@ class WordGeneratorTest(TestCase):
descriptionPrefix = "passlib.pwd.genword()"
def setUp(self):
- super(WordGeneratorTest, self).setUp()
+ super().setUp()
# patch some RNG references so they're reproducible.
from passlib.pwd import SequenceGenerator
diff --git a/passlib/tests/test_registry.py b/passlib/tests/test_registry.py
index 2e00977..09d8dfd 100644
--- a/passlib/tests/test_registry.py
+++ b/passlib/tests/test_registry.py
@@ -39,7 +39,7 @@ class RegistryTest(TestCase):
descriptionPrefix = "passlib.registry"
def setUp(self):
- super(RegistryTest, self).setUp()
+ super().setUp()
# backup registry state & restore it after test.
locations = dict(registry._locations)
diff --git a/passlib/tests/test_totp.py b/passlib/tests/test_totp.py
index 999c799..e9c6dd9 100644
--- a/passlib/tests/test_totp.py
+++ b/passlib/tests/test_totp.py
@@ -396,7 +396,7 @@ class TotpTest(TestCase):
# setup
#=============================================================================
def setUp(self):
- super(TotpTest, self).setUp()
+ super().setUp()
# clear norm_hash_name() cache so 'unknown hash' warnings get emitted each time
from passlib.crypto.digest import lookup_hash
diff --git a/passlib/tests/test_utils_handlers.py b/passlib/tests/test_utils_handlers.py
index a9c3b05..f665aac 100644
--- a/passlib/tests/test_utils_handlers.py
+++ b/passlib/tests/test_utils_handlers.py
@@ -51,7 +51,7 @@ class SkeletonTest(TestCase):
checksum_size = 1
def __init__(self, flag=False, **kwds):
- super(d1, self).__init__(**kwds)
+ super().__init__(**kwds)
self.flag = flag
def _calc_checksum(self, secret):
diff --git a/passlib/tests/test_utils_md4.py b/passlib/tests/test_utils_md4.py
index 5d824a1..e3e04d4 100644
--- a/passlib/tests/test_utils_md4.py
+++ b/passlib/tests/test_utils_md4.py
@@ -29,7 +29,7 @@ class Legacy_MD4_Test(_Common_MD4_Test):
descriptionPrefix = "passlib.utils.md4.md4()"
def setUp(self):
- super(Legacy_MD4_Test, self).setUp()
+ super().setUp()
warnings.filterwarnings("ignore", ".*passlib.utils.md4.*deprecated", DeprecationWarning)
def get_md4_const(self):
diff --git a/passlib/tests/test_utils_pbkdf2.py b/passlib/tests/test_utils_pbkdf2.py
index f87726d..0e10248 100644
--- a/passlib/tests/test_utils_pbkdf2.py
+++ b/passlib/tests/test_utils_pbkdf2.py
@@ -52,7 +52,7 @@ class Pbkdf1_Test(TestCase):
)
def setUp(self):
- super(Pbkdf1_Test, self).setUp()
+ super().setUp()
warnings.filterwarnings("ignore", ".*passlib.utils.pbkdf2.*deprecated", DeprecationWarning)
def test_known(self):
@@ -207,7 +207,7 @@ class Pbkdf2_Test(TestCase):
]
def setUp(self):
- super(Pbkdf2_Test, self).setUp()
+ super().setUp()
warnings.filterwarnings("ignore", ".*passlib.utils.pbkdf2.*deprecated", DeprecationWarning)
def test_known(self):
diff --git a/passlib/tests/utils.py b/passlib/tests/utils.py
index 1880dd9..d00d30a 100644
--- a/passlib/tests/utils.py
+++ b/passlib/tests/utils.py
@@ -314,7 +314,7 @@ class TestCase(unittest.TestCase):
def shortDescription(self):
"""wrap shortDescription() method to prepend descriptionPrefix"""
- desc = super(TestCase, self).shortDescription()
+ desc = super().shortDescription()
prefix = self.descriptionPrefix
if prefix:
desc = "%s: %s" % (prefix, desc or str(self))
@@ -347,7 +347,7 @@ class TestCase(unittest.TestCase):
resetWarningState = True
def setUp(self):
- super(TestCase, self).setUp()
+ super().setUp()
self.setUpWarnings()
# have uh.debug_only_repr() return real values for duration of test
self.patchAttr(exc, "ENABLE_DEBUG_ONLY_REPR", True)
@@ -389,7 +389,7 @@ class TestCase(unittest.TestCase):
msg = kwds.pop("__msg__", None)
if _callable is None:
# FIXME: this ignores 'msg'
- return super(TestCase, self).assertRaises(_exc_type, None,
+ return super().assertRaises(_exc_type, None,
*args, **kwds)
try:
result = _callable(*args, **kwds)
@@ -462,14 +462,13 @@ class TestCase(unittest.TestCase):
def __init__(self, case, **kwds):
self.case = case
self.kwds = kwds
- self.__super = super(TestCase._AssertWarningList, self)
- self.__super.__init__(record=True)
+ super().__init__(record=True)
def __enter__(self):
- self.log = self.__super.__enter__()
+ self.log = super().__enter__()
def __exit__(self, *exc_info):
- self.__super.__exit__(*exc_info)
+ super().__exit__(*exc_info)
if exc_info[0] is None:
self.case.assertWarningList(self.log, **self.kwds)
@@ -995,7 +994,7 @@ class HandlerCase(TestCase):
if test_requires_backend and self._skip_backend_reason:
raise self.skipTest(self._skip_backend_reason)
- super(HandlerCase, self).setUp()
+ super().setUp()
# if needed, select specific backend for duration of test
# NOTE: skipping this if create_backend_case() signalled we're skipping backend
@@ -3134,7 +3133,7 @@ class OsCryptMixin(HandlerCase):
if not self.handler.has_backend("os_crypt"):
# XXX: currently, any tests that use this are skipped entirely! (see issue 120)
self._patch_safe_crypt()
- super(OsCryptMixin, self).setUp()
+ super().setUp()
@classmethod
def _get_safe_crypt_handler_backend(cls):
@@ -3191,7 +3190,7 @@ class OsCryptMixin(HandlerCase):
when it's known os_crypt will be faked by _patch_safe_crypt()
"""
assert backend == "os_crypt"
- reason = super(OsCryptMixin, cls)._get_skip_backend_reason(backend)
+ reason = super()._get_skip_backend_reason(backend)
from passlib.utils import has_crypt
if reason == cls._BACKEND_NOT_AVAILABLE and has_crypt:
@@ -3493,13 +3492,13 @@ class reset_warnings(warnings.catch_warnings):
"""catch_warnings() wrapper which clears warning registry & filters"""
def __init__(self, reset_filter="always", reset_registry=".*", **kwds):
- super(reset_warnings, self).__init__(**kwds)
+ super().__init__(**kwds)
self._reset_filter = reset_filter
self._reset_registry = re.compile(reset_registry) if reset_registry else None
def __enter__(self):
# let parent class archive filter state
- ret = super(reset_warnings, self).__enter__()
+ ret = super().__enter__()
# reset the filter to list everything
if self._reset_filter:
@@ -3538,7 +3537,7 @@ class reset_warnings(warnings.catch_warnings):
setattr(mod, "__warningregistry__", orig)
else:
reg.update(orig)
- super(reset_warnings, self).__exit__(*exc_info)
+ super().__exit__(*exc_info)
#=============================================================================
# eof
diff --git a/passlib/totp.py b/passlib/totp.py
index 17ac3bd..a133354 100644
--- a/passlib/totp.py
+++ b/passlib/totp.py
@@ -751,7 +751,7 @@ class TOTP(object):
new=False, digits=None, alg=None, size=None, period=None,
label=None, issuer=None, changed=False,
**kwds):
- super(TOTP, self).__init__(**kwds)
+ super().__init__(**kwds)
if changed:
self.changed = changed
diff --git a/passlib/utils/binary.py b/passlib/utils/binary.py
index 745366f..f60ddf2 100644
--- a/passlib/utils/binary.py
+++ b/passlib/utils/binary.py
@@ -852,7 +852,7 @@ class LazyBase64Engine(Base64Engine):
def _lazy_init(self):
args, kwds = self._lazy_opts
- super(LazyBase64Engine, self).__init__(*args, **kwds)
+ super().__init__(*args, **kwds)
del self._lazy_opts
self.__class__ = Base64Engine
diff --git a/passlib/utils/handlers.py b/passlib/utils/handlers.py
index 97ac757..cea096c 100644
--- a/passlib/utils/handlers.py
+++ b/passlib/utils/handlers.py
@@ -449,7 +449,7 @@ class TruncateMixin(MinimalHandler):
@classmethod
def using(cls, truncate_error=None, **kwds):
- subcls = super(TruncateMixin, cls).using(**kwds)
+ subcls = super().using(**kwds)
if truncate_error is not None:
truncate_error = as_bool(truncate_error, param="truncate_error")
if truncate_error is not None:
@@ -615,7 +615,7 @@ class GenericHandler(MinimalHandler):
#===================================================================
def __init__(self, checksum=None, use_defaults=False, **kwds):
self.use_defaults = use_defaults
- super(GenericHandler, self).__init__(**kwds)
+ super().__init__(**kwds)
if checksum is not None:
# XXX: do we need to set .relaxed for checksum coercion?
self.checksum = self._norm_checksum(checksum)
@@ -902,7 +902,7 @@ class GenericHandler(MinimalHandler):
def bitsize(cls, **kwds):
"""[experimental method] return info about bitsizes of hash"""
try:
- info = super(GenericHandler, cls).bitsize(**kwds)
+ info = super().bitsize(**kwds)
except AttributeError:
info = {}
cc = ALL_BYTE_VALUES if cls._checksum_is_bytes else cls.checksum_chars
@@ -973,7 +973,7 @@ class HasEncodingContext(GenericHandler):
default_encoding = "utf-8"
def __init__(self, encoding=None, **kwds):
- super(HasEncodingContext, self).__init__(**kwds)
+ super().__init__(**kwds)
self.encoding = encoding or self.default_encoding
class HasUserContext(GenericHandler):
@@ -981,7 +981,7 @@ class HasUserContext(GenericHandler):
context_kwds = ("user",)
def __init__(self, user=None, **kwds):
- super(HasUserContext, self).__init__(**kwds)
+ super().__init__(**kwds)
self.user = user
# XXX: would like to validate user input here, but calls to from_string()
@@ -990,16 +990,16 @@ class HasUserContext(GenericHandler):
# wrap funcs to accept 'user' as positional arg for ease of use.
@classmethod
def hash(cls, secret, user=None, **context):
- return super(HasUserContext, cls).hash(secret, user=user, **context)
+ return super().hash(secret, user=user, **context)
@classmethod
def verify(cls, secret, hash, user=None, **context):
- return super(HasUserContext, cls).verify(secret, hash, user=user, **context)
+ return super().verify(secret, hash, user=user, **context)
@deprecated_method(deprecated="1.7", removed="2.0")
@classmethod
def genhash(cls, secret, config, user=None, **context):
- return super(HasUserContext, cls).genhash(secret, config, user=user, **context)
+ return super().genhash(secret, config, user=user, **context)
# XXX: how to guess the entropy of a username?
# most of these hashes are for a system (e.g. Oracle)
@@ -1008,7 +1008,7 @@ class HasUserContext(GenericHandler):
# need to find good reference about this.
##@classmethod
##def bitsize(cls, **kwds):
- ## info = super(HasUserContext, cls).bitsize(**kwds)
+ ## info = super().bitsize(**kwds)
## info['user'] = xxx
## return info
@@ -1091,7 +1091,7 @@ class HasManyIdents(GenericHandler):
default_ident = ident
# create subclass
- subcls = super(HasManyIdents, cls).using(**kwds)
+ subcls = super().using(**kwds)
# add custom default ident
# (NOTE: creates instance to run value through _norm_ident())
@@ -1103,7 +1103,7 @@ class HasManyIdents(GenericHandler):
# init
#===================================================================
def __init__(self, ident=None, **kwds):
- super(HasManyIdents, self).__init__(**kwds)
+ super().__init__(**kwds)
# init ident
if ident is not None:
@@ -1290,7 +1290,7 @@ class HasSalt(GenericHandler):
default_salt_size = salt_size
# generate new subclass
- subcls = super(HasSalt, cls).using(**kwds)
+ subcls = super().using(**kwds)
# replace default_rounds
relaxed = kwds.get("relaxed")
@@ -1363,7 +1363,7 @@ class HasSalt(GenericHandler):
# init
#===================================================================
def __init__(self, salt=None, **kwds):
- super(HasSalt, self).__init__(**kwds)
+ super().__init__(**kwds)
if salt is not None:
salt = self._parse_salt(salt)
elif self.use_defaults:
@@ -1452,7 +1452,7 @@ class HasSalt(GenericHandler):
@classmethod
def bitsize(cls, salt_size=None, **kwds):
"""[experimental method] return info about bitsizes of hash"""
- info = super(HasSalt, cls).bitsize(**kwds)
+ info = super().bitsize(**kwds)
if salt_size is None:
salt_size = cls.default_salt_size
# FIXME: this may overestimate size due to padding bits
@@ -1607,7 +1607,7 @@ class HasRounds(GenericHandler):
default_rounds = rounds
# generate new subclass
- subcls = super(HasRounds, cls).using(**kwds)
+ subcls = super().using(**kwds)
# replace min_desired_rounds
relaxed = kwds.get("relaxed")
@@ -1748,7 +1748,7 @@ class HasRounds(GenericHandler):
# init
#===================================================================
def __init__(self, rounds=None, **kwds):
- super(HasRounds, self).__init__(**kwds)
+ super().__init__(**kwds)
if rounds is not None:
rounds = self._parse_rounds(rounds)
elif self.use_defaults:
@@ -1830,7 +1830,7 @@ class HasRounds(GenericHandler):
max_desired_rounds = self.max_desired_rounds
if max_desired_rounds and self.rounds > max_desired_rounds:
return True
- return super(HasRounds, self)._calc_needs_update(**kwds)
+ return super()._calc_needs_update(**kwds)
#===================================================================
# experimental methods
@@ -1838,7 +1838,7 @@ class HasRounds(GenericHandler):
@classmethod
def bitsize(cls, rounds=None, vary_rounds=.1, **kwds):
"""[experimental method] return info about bitsizes of hash"""
- info = super(HasRounds, cls).bitsize(**kwds)
+ info = super().bitsize(**kwds)
# NOTE: this essentially estimates how many bits of "salt"
# can be added by varying the rounds value just a little bit.
if cls.rounds_cost != "log2":
@@ -1887,7 +1887,7 @@ class ParallelismMixin(GenericHandler):
@classmethod
def using(cls, parallelism=None, **kwds):
- subcls = super(ParallelismMixin, cls).using(**kwds)
+ subcls = super().using(**kwds)
if parallelism is not None:
if isinstance(parallelism, str):
parallelism = int(parallelism)
@@ -1898,7 +1898,7 @@ class ParallelismMixin(GenericHandler):
# init
#===================================================================
def __init__(self, parallelism=None, **kwds):
- super(ParallelismMixin, self).__init__(**kwds)
+ super().__init__(**kwds)
# init parallelism
if parallelism is None:
@@ -1922,7 +1922,7 @@ class ParallelismMixin(GenericHandler):
# XXX: for now, marking all hashes which don't have matching parallelism setting
if self.parallelism != type(self).parallelism:
return True
- return super(ParallelismMixin, self)._calc_needs_update(**kwds)
+ return super()._calc_needs_update(**kwds)
#===================================================================
# eoc
@@ -2265,7 +2265,7 @@ class SubclassBackendMixin(BackendMixin):
@classmethod
def _set_backend(cls, name, dryrun):
# invoke backend loader (will throw error if fails)
- super(SubclassBackendMixin, cls)._set_backend(name, dryrun)
+ super()._set_backend(name, dryrun)
# sanity check call args (should trust .set_backend, but will really
# foul things up if this isn't the owner)