-
Notifications
You must be signed in to change notification settings - Fork 18
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 better types to models.py #1885
Draft
smcmurtry
wants to merge
6
commits into
main
Choose a base branch
from
feat/types-in-models-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b7d204d
adding the correct types to models.py
smcmurtry f95975f
Merge branch 'main' into feat/types-in-models-2
smcmurtry d943c62
Merge branch 'main' into feat/types-in-models-2
smcmurtry 77cc1e2
merged in main
smcmurtry e6017de
Merge branch 'feat/types-in-models-2' of github.com:cds-snc/notificat…
smcmurtry 6283f60
Merge branch 'main' into feat/types-in-models-2
smcmurtry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from sqlalchemy import * # noqa: F401,F403 | ||
from sqlalchemy.orm import * # noqa: F401,F403 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
import itertools | ||
import uuid | ||
from enum import Enum | ||
from typing import Any, Iterable, Literal | ||
from typing import Any, Iterable, Literal, cast | ||
|
||
from flask import current_app, url_for | ||
from flask_sqlalchemy.model import DefaultMeta | ||
|
@@ -33,6 +33,7 @@ | |
from app import ( | ||
DATETIME_FORMAT, | ||
db, | ||
db_type, | ||
signer_api_key, | ||
signer_bearer_token, | ||
signer_inbound_sms, | ||
|
@@ -50,6 +51,7 @@ | |
|
||
TEMPLATE_TYPES = [SMS_TYPE, EMAIL_TYPE, LETTER_TYPE] | ||
|
||
db = cast(db_type, db) # type: ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And a comment to explain why we need to cast it to the module's type. 👍 |
||
template_types = db.Enum(*TEMPLATE_TYPES, name="template_type") | ||
|
||
NORMAL = "normal" | ||
|
@@ -88,7 +90,7 @@ def update_from_original(self, original): | |
current_app.logger.debug("{} has no column {} to copy from".format(original, c.name)) | ||
|
||
|
||
BaseModel: DefaultMeta = db.Model | ||
BaseModel: DefaultMeta = db.Model # type: ignore | ||
|
||
|
||
class User(BaseModel): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Let's please document the purpose of this file with a docstring, explaining why this is necessary.