-
Notifications
You must be signed in to change notification settings - Fork 42
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
Complete type annotation in current Python code #25
Comments
Not sure how far we want to go with type annotations, but while PEP 484 is supported by Python 3.5, PEP 526 requires 3.6. Lines 6 to 7 in cb14171
|
I must admit, I have reservations about type annotations (basically, they don't make any difference to the running code, and I'm not even sure they make code more readable). If we were to use them to aid us check the "correctness" of our code then it's a "guarded" +1 for me, and this should be added to CI / automation in |
@ntoll Pretty sure automated testing is @kushaldas's intention. freedomofpress/securedrop-sdk#26 |
+1 |
I'm renaming this ticket because as it stands it's an ongoing directive and not an actionable task. |
Before we add significant type checking in this repo, we may want to implement #1764 to make the typechecks in this repo more meaningful. |
Discussed in backlog review, not fully resolved yet. The following files are currently targeted for strict mypy type checks:
It would be good to generate automated coverage reports, if possible, so we can gradually get to full coverage. |
The following files need to be updated to fix type annotation issues: securedrop_client/sync.py Then I believe we can make the following change: diff --git a/Makefile b/Makefile
index d3421d8..1f7816d 100644
--- a/Makefile
+++ b/Makefile
@@ -40,22 +40,12 @@ check-isort: ## Check Python import organization with isort
.PHONY: mypy
mypy: ## Run static type checker
- @mypy --ignore-missing-imports securedrop_client
- @# Add files that are 100% typed to the below call (eventually just the below line will run so that code without static type hints will fail CI)
@mypy --ignore-missing-imports \
--disallow-incomplete-defs \
--disallow-untyped-defs \
- securedrop_client/db.py \
- securedrop_client/crypto.py \
- securedrop_client/config.py \
- securedrop_client/gui/__init__.py \
- securedrop_client/resources/__init__.py \
- securedrop_client/storage.py \
- securedrop_client/queue.py \
- securedrop_client/api_jobs/__init__.py \
- securedrop_client/api_jobs/base.py \
- securedrop_client/api_jobs/downloads.py \
- securedrop_client/api_jobs/uploads.py
+ *.py \
+ securedrop_client/*.py \
+ securedrop_client/**/*.py
.PHONY: clean
clean: ## Clean the workspace of generated resources |
I've a starting point in #1312; I'm picking this up. |
Because we are writing complete new code and also in Python3, we should have type annotations in all of our code.
Edited by @redshiftzero:
Let's do this in multiple PRs to minimize disruption and review burden:
The text was updated successfully, but these errors were encountered: