Today I tried to install on debian 11 (I know, it's old) running python 3.9.2 which is supported according to the docs.
I encountered an issue due to the type hinting in
def site_theme(self) -> str|None:
when running flask commands:
File "liberaforms/liberaforms/models/user.py", line 257, in User
def site_theme(self) -> str|None:
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
If I remove the |None type hint the command runs successfully
That type hint seems to be the only '| None' present, the syntax seems to be supported on python > 3.10
maybe the following could be used
--- a/liberaforms/models/user.py
+++ b/liberaforms/models/user.py
@@ -8,6 +8,7 @@ This file is part of LiberaForms.
import os
import shutil
from datetime import datetime, timezone
+from typing import Optional
from sqlalchemy import and_, select, func
from sqlalchemy.orm import query_expression
from sqlalchemy.orm.attributes import flag_modified
@@ -254,7 +255,7 @@ class User(_User):
"""User preference for new Forms."""
return self.preferences["newAnswerNotification"]
- def site_theme(self) -> str|None:
+ def site_theme(self) -> Optional[str]:
return self.preferences['site-theme'] if 'site-theme' in self.preferences else None
def one_answer_only_default(self) -> bool
Even if all this only to support python 3.9.2 may not be desired
Today I tried to install on debian 11 (I know, it's old) running python 3.9.2 which is supported according to the docs.
I encountered an issue due to the type hinting in
https://codeberg.org/LiberaForms/server/src/commit/3e29e24d5a3dac6a3594a2cdd44b9ffe66b8c2ef/liberaforms/models/user.py#L257 when running flask commands:
```
File "liberaforms/liberaforms/models/user.py", line 257, in User
def site_theme(self) -> str|None:
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
```
If I remove the `|None` type hint the command runs successfully
That type hint seems to be the only '| None' present, the syntax seems to be supported on python > 3.10
maybe the following could be used
```patch
--- a/liberaforms/models/user.py
+++ b/liberaforms/models/user.py
@@ -8,6 +8,7 @@ This file is part of LiberaForms.
import os
import shutil
from datetime import datetime, timezone
+from typing import Optional
from sqlalchemy import and_, select, func
from sqlalchemy.orm import query_expression
from sqlalchemy.orm.attributes import flag_modified
@@ -254,7 +255,7 @@ class User(_User):
"""User preference for new Forms."""
return self.preferences["newAnswerNotification"]
- def site_theme(self) -> str|None:
+ def site_theme(self) -> Optional[str]:
return self.preferences['site-theme'] if 'site-theme' in self.preferences else None
def one_answer_only_default(self) -> bool
```
Even if all this only to support python 3.9.2 may not be desired