Skip to content

Commit

Permalink
Merge branch 'develop' into chore_migration
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannicimolin authored Jan 27, 2024
2 parents 1fa7bf7 + dd7b062 commit 91a186d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
4 changes: 2 additions & 2 deletions knox/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def authenticate_credentials(self, token):
return self.validate_user(auth_token)
raise exceptions.AuthenticationFailed(msg)

def renew_token(self, auth_token):
def renew_token(self, auth_token) -> None:
current_expiry = auth_token.expiry
new_expiry = timezone.now() + knox_settings.TOKEN_TTL
auth_token.expiry = new_expiry
Expand All @@ -89,7 +89,7 @@ def validate_user(self, auth_token):
def authenticate_header(self, request):
return knox_settings.AUTH_HEADER_PREFIX

def _cleanup_token(self, auth_token):
def _cleanup_token(self, auth_token) -> bool:
for other_token in auth_token.user.auth_token_set.all():
if other_token.digest != auth_token.digest and other_token.expiry:
if other_token.expiry < timezone.now():
Expand Down
4 changes: 2 additions & 2 deletions knox/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
hash_func = knox_settings.SECURE_HASH_ALGORITHM


def create_token_string():
def create_token_string() -> str:
return binascii.hexlify(
generate_bytes(int(knox_settings.AUTH_TOKEN_CHARACTER_LENGTH / 2))
).decode()


def make_hex_compatible(token: str) -> str:
def make_hex_compatible(token: str) -> bytes:
"""
We need to make sure that the token, that is send is hex-compatible.
When a token prefix is used, we cannot guarantee that.
Expand Down
1 change: 0 additions & 1 deletion knox/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class Meta:
def __str__(self):
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):
class Meta:
swappable = 'KNOX_TOKEN_MODEL'
Expand Down
2 changes: 1 addition & 1 deletion knox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ def __setattr__(self, *args, **kwargs):
''')


CONSTANTS = CONSTANTS()
CONSTANTS = CONSTANTS() # type: ignore
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
],

# What does your project relate to?
Expand Down
13 changes: 7 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ envlist =
isort,
flake8,
py{36,37,38,39,310}-django32,
py{38,39,310}-django40,
py{38,39,310,311}-django41,
py{38,39,310,311,312}-django42,
py{310,311,312}-django50,

[testenv:flake8]
deps = flake8
Expand All @@ -30,8 +30,8 @@ setenv =
PIP_INDEX_URL = https://pypi.python.org/simple/
deps =
django32: Django>=3.2,<3.3
django40: Django>=4.0,<4.1
django41: Django>=4.1.3,<4.2
django42: Django>=4.2,<4.3
django50: Django>=5.0,<5.1
markdown>=3.0
isort>=5.0
djangorestframework
Expand All @@ -49,5 +49,6 @@ python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310, isort, flake8
3.11: py311
3.10: py310
3.11: py311, isort, flake8
3.12: py312

0 comments on commit 91a186d

Please sign in to comment.