-
Notifications
You must be signed in to change notification settings - Fork 28
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
refact(backend-lifespan): improving type checking and incorporating lifespan as an alternative to on_event #394
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Quality Gate passedIssues Measures |
if not payload.get("created_at"): | ||
return | ||
if dbadmin.password_reset_at > payload.get("created_at"): | ||
if bool(dbadmin.password_reset_at): |
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.
no need to cast into boolean
if db_user is User and db_user.key == key: | ||
return db_user | ||
else: | ||
raise HTTPException(status_code=404, detail="User not found") |
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.
no detail here
@@ -90,15 +89,15 @@ def get_user( | |||
def parse_start_date(start: str | None = None): | |||
if not start: | |||
return datetime.fromtimestamp( | |||
datetime.utcnow().timestamp() - 30 * 24 * 3600 | |||
datetime.now().timestamp() - 30 * 24 * 3600 |
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.
switch back to utcnow for now so api support is not broken
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.
actually causes internal problem
) | ||
else: | ||
return datetime.fromisoformat(start) | ||
|
||
|
||
def parse_end_date(end: str | None = None): | ||
if not end: | ||
return datetime.utcnow() | ||
return datetime.now() |
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.
same
@@ -95,10 +95,10 @@ def modify_admin( | |||
raise HTTPException(status_code=404, detail="Admin not found") | |||
|
|||
# If a sudoer admin wants to edit another sudoer | |||
if (username != admin.username) and dbadmin.is_sudo: | |||
if username != admin.username and bool(dbadmin.is_sudo): |
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.
no need to cast to bool here too
@@ -111,10 +111,10 @@ def remove_admin(username: str, db: DBDep, admin: SudoAdminDep): | |||
if not dbadmin: | |||
raise HTTPException(status_code=404, detail="Admin not found") | |||
|
|||
if dbadmin.is_sudo: | |||
if bool(dbadmin.is_sudo): |
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.
same
Description
This PR aims to resolve few type checking errors and replacing deprecated features of Fast API with new alternative ones.
API Changes
on_event
for graceful shutdown and disposability with lifespan.Checklist