Skip to content

Commit

Permalink
fix: py310 unit tests
Browse files Browse the repository at this point in the history
For some reasons, list["Client"] does not resolve the ForwardRef in
python 3.10 as it does with typing.List["Client"], which in the end
breaks the memory backend model accessors.
  • Loading branch information
azmeuk committed Oct 28, 2024
1 parent 0b51b01 commit 6b5e3e1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions canaille/oidc/basemodels.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import datetime
from typing import ClassVar

# keep 'List' instead of 'list' for audiences to not break py310 with the memory backend
from typing import List # noqa: UP035

from canaille.backends.models import Model
from canaille.core.models import User

Expand All @@ -18,7 +21,8 @@ class Client(Model):

description: str | None = None
preconsent: bool | None = False
audience: list["Client"] = []
# keep 'List' instead of 'list' do not break py310 with the memory backend
audience: List["Client"] = [] # noqa: UP006

client_id: str | None
"""REQUIRED.
Expand Down Expand Up @@ -320,7 +324,8 @@ class Token(Model):
issue_date: datetime.datetime
lifetime: int
revokation_date: datetime.datetime
audience: list["Client"]
# keep 'List' instead of 'list' do not break py310 with the memory backend
audience: List["Client"] # noqa: UP006


class Consent(Model):
Expand Down

0 comments on commit 6b5e3e1

Please sign in to comment.