-
Notifications
You must be signed in to change notification settings - Fork 693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add type annotations for source_app/utils.py #5300
Add type annotations for source_app/utils.py #5300
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
one other thought: in other parts of the server codebase we have the imports needed only for type checking in a if TYPE_CHECKING
block so they're not imported at runtime - @kushaldas (or others interested) want to keep doing that or no strong thoughts? I'll approve but not merge so folks have a chance to weigh in.
I prefer things under |
I'll take a look at how the conditional import is done elsewhere and add this in! |
d3c3a77
to
62f5ec8
Compare
@pierwill Looks like linter is still unhappy, would you like help resolving these linter issues? |
That would be great! I haven't had time to troubleshoot this lately... |
No worries, @kushaldas will poke at it a bit more tomorrow. |
This fixes the issue for me. diff --git a/securedrop/source_app/utils.py b/securedrop/source_app/utils.py
index 3e430a81f..6c72a6de9 100644
--- a/securedrop/source_app/utils.py
+++ b/securedrop/source_app/utils.py
@@ -10,10 +10,6 @@ from threading import Thread
import typing
-if typing.TYPE_CHECKING:
- from typing import Optional # noqa: F401
-
-
import i18n
import re
@@ -21,6 +17,9 @@ from crypto_util import CryptoUtil, CryptoException
from models import Source
from sdconfig import SDConfig
+if typing.TYPE_CHECKING:
+ from typing import Optional # noqa: F401
+
def logged_in() -> bool:
return 'logged_in' in session
|
Also add conditional import for type checking. This commit is work towards freedomofpress#4399.
d225bb0
to
0a902da
Compare
Squashed and linted! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks for all the work on this @pierwill.
Status
Ready for review.
I've posed a few questions on specific types in the comments below.
Description of Changes
This is work towards #4399.