Skip to content

Commit

Permalink
chore(migration): use f-string; no arguments for super()
Browse files Browse the repository at this point in the history
  • Loading branch information
Rotzbua committed Oct 10, 2023
1 parent bc7c284 commit a87e222
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions knox/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create(
digest = crypto.hash_token(token)
if expiry is not None:
expiry = timezone.now() + expiry
instance = super(AuthTokenManager, self).create(
instance = super().create(
token_key=token[:CONSTANTS.TOKEN_KEY_LENGTH], digest=digest,
user=user, expiry=expiry)
return instance, token
Expand All @@ -49,7 +49,7 @@ class Meta:
abstract = True

def __str__(self):
return '%s : %s' % (self.digest, self.user)
return f'{self.digest} : {self.user}'

Check warning on line 52 in knox/models.py

View check run for this annotation

Codecov / codecov/patch

knox/models.py#L52

Added line #L52 was not covered by tests


class AuthToken(AbstractAuthToken):
Expand Down
4 changes: 2 additions & 2 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

def get_basic_auth_header(username, password):
return 'Basic %s' % base64.b64encode(
('%s:%s' % (username, password)).encode('ascii')).decode()
(f'{username}:{password}').encode('ascii')).decode()


auto_refresh_knox = knox_settings.defaults.copy()
Expand Down Expand Up @@ -198,7 +198,7 @@ def test_update_token_key(self):
instance, token = AuthToken.objects.create(self.user)
rf = APIRequestFactory()
request = rf.get('/')
request.META = {'HTTP_AUTHORIZATION': 'Token {}'.format(token)}
request.META = {'HTTP_AUTHORIZATION': f'Token {token}'}
(self.user, auth_token) = TokenAuthentication().authenticate(request)
self.assertEqual(
token[:CONSTANTS.TOKEN_KEY_LENGTH],
Expand Down

0 comments on commit a87e222

Please sign in to comment.