4
20
Fork
You've already forked server
8

Error installing with python 3.9.2 #802

Closed
opened 2025年09月28日 12:39:08 +02:00 by svalo · 5 comments

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

Yes, I stumbled across that the other day too. Thanks for the fix! It will be included.

Cheers :)

Yes, I stumbled across that the other day too. Thanks for the fix! It will be included. Cheers :)

python 3.9.2 which is supported according to the docs

I'd forgotten to run the tests against that version. (should be ideally automated)

> python 3.9.2 which is supported according to the docs I'd forgotten to run the tests against that version. (should be ideally automated)
Author
Copy link

Thank you!

Thank you!

Opps! Forgot to add this to the last release.. :(

In develop now 22de420d02

Opps! Forgot to add this to the last release.. :( In develop now https://codeberg.org/LiberaForms/server/commit/22de420d02e042ece6f3098cfec3c1d7626c73ac

Released in v4.6.1

Thanks for opening the issue!

Released in v4.6.1 Thanks for opening the issue!
Sign in to join this conversation.
No Branch/Tag specified
main
chore/L10n-formbuilder
chore/L10n-public-form
chore/L10n-form-templates
chore/L10n
chore/L10n-inline-help
feat/form-quiz
develop
RC
feature/pyproject
fix/image-public-urls-json
fix/email-multipart
feat/user-honeypots
feat/auto-expire-purge-forms
feat/ldap-authentik
feat/middleware-limiter
feat/auto-expire
feat/form-name-in-title-and-opengraph
tests/fake-email-server
feat/page-break-form-field
feat/bulk-file-download
feat/data-display-media-type
feat/inline-help
feat/poetry
chore/L10n-parsley
bogus-form-submit
feat/public-form-i18n
fix/L10n
chore/upgrade-py-libraries
feat/star-rating-form-field
chore/upgrade-formbuilder-core
fix_PIL_error_wrong_mimetype_saving
feat/extended-form-fields
feat/webhooks
fix/array-value-bug
feat/form-themes
bugfix-plaintext-answer-edit
feat/moderator-role
fix/auth-wrapper
feat/conditional-fields
feat/data-download
feat/pdf-media
chore/tests
feat/postgres-orm
v5.0.0-dev-1
v4.10.0
v4.9.3
v4.9.2
v4.9.1
v4.9.0
v4.9.0-dev-6
v4.9.0-dev-5
v4.9.0-dev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-dev-11
v2.0.0-dev-10
v2.0.0-dev-9
v2.0.0-dev-8
v2.0.0-dev-7
v2.0.0-dev-6
v2.0.0-dev-5
v2.0.0-dev-4
v2.0.0-dev-3
v2.0.0-dev-2
v2.0.0-dev-1
v2.0.0-dev
list
v1.8.13
pre-mongoengine
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
LiberaForms/server#802
Reference in a new issue
LiberaForms/server
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?