misc: apply black 22.1.0

This commit is contained in:
Frédéric Péters 2022-03-01 19:34:11 +01:00
parent 16a1ca1ac7
commit 09c2a08d11
6 changed files with 16 additions and 15 deletions

View File

@ -61,7 +61,7 @@ class Page:
@cached_property
def last_page_url(self):
return self.form.make_url('before_cursor', '%s 0' % (2 ** 31 - 1))
return self.form.make_url('before_cursor', '%s 0' % (2**31 - 1))
def __bool__(self):
return bool(self.events)

View File

@ -276,11 +276,11 @@ class EventManager(models.Manager):
def n_2_pairing(a, b):
return a * 2 ** 32 + b
return a * 2**32 + b
def n_2_pairing_rev(n):
return (n >> 32, n & (2 ** 32 - 1))
return (n >> 32, n & (2**32 - 1))
def reference_integer(instance):

View File

@ -80,7 +80,7 @@ class ExponentialRetryTimeout:
else:
level, next_time = what
level += 1
duration = min(self.duration * self.factor ** level, self.max_duration)
duration = min(self.duration * self.factor**level, self.max_duration)
next_time += duration
cache.set(key, (level, next_time), self.cache_duration)
self.logger.debug('failure for %s, level: %s, next_time: %s', keys, level, next_time)

View File

@ -162,7 +162,11 @@ def int_to_cryptobinary(integer):
def get_xmldsig_rsa_key_value(publickey):
mod = get_rsa_public_key_modulus(publickey)
exp = get_rsa_public_key_exponent(publickey)
return '<RSAKeyValue' ' xmlns="http://www.w3.org/2000/09/xmldsig#">\n\t<Modulus>%s</Modulus>\n\t<Exponent>%s</Exponent>\n</RSAKeyValue>' % (
int_to_cryptobinary(mod),
int_to_cryptobinary(exp),
return (
'<RSAKeyValue'
' xmlns="http://www.w3.org/2000/09/xmldsig#">\n\t<Modulus>%s</Modulus>\n\t<Exponent>%s</Exponent>\n</RSAKeyValue>'
% (
int_to_cryptobinary(mod),
int_to_cryptobinary(exp),
)
)

View File

@ -276,13 +276,10 @@ def oidc_provider_mock(
}.get(oidc_provider.idtoken_algo)
jwk = None
for key in oidc_provider_jwkset['keys']:
if (
key.key_type
== {
OIDCProvider.ALGO_RSA: 'RSA',
OIDCProvider.ALGO_EC: 'EC',
}.get(oidc_provider.idtoken_algo)
):
if key.key_type == {
OIDCProvider.ALGO_RSA: 'RSA',
OIDCProvider.ALGO_EC: 'EC',
}.get(oidc_provider.idtoken_algo):
jwk = key
break
if provides_kid_header:

View File

@ -146,7 +146,7 @@ def test_exponential_backoff(db, app, settings):
response.form.set('username', 'zozo')
response.form.set('password', 'zozo')
response = response.form.submit('login-password-submit')
if 1.8 ** i > 10:
if 1.8**i > 10:
break
assert 'too many login' not in response.text, '%s' % i
assert 'too many login' in response.text, '%s' % i