chore: handle django_q not present in requirements - #61
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates fyle-rest-auth to avoid importing django_q at module import time by switching to runtime loading of django_q.tasks.async_task, and bumps the package version accordingly.
Changes:
- Bumped package version from
1.8.4to1.8.5. - Removed top-level
django_qimport and switched toimport_string('django_q.tasks.async_task')at call sites for async updates.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| setup.py | Bumps the package version to 1.8.5. |
| fyle_rest_auth/helpers.py | Replaces eager django_q import with runtime loading of async_task for optional async credential updates. |
Suppressed comments (3)
fyle_rest_auth/helpers.py:86
- If
django_qisn’t installed,import_string('django_q.tasks.async_task')raises ImportError and the whole login flow fails (caught by the outerexcept Exceptionand re-raised as ValidationError). Since the PR goal is to toleratedjango_qbeing absent, guard this import and fall back to the synchronous task (or skip) instead of failing authentication.
This issue also appears in the following locations of the same file:
- line 145
- line 157
if 'async_update_user' in settings.FYLE_REST_AUTH_SETTINGS:
if settings.FYLE_REST_AUTH_SETTINGS['async_update_user']:
async_task = import_string('django_q.tasks.async_task')
async_task(
'apps.workspaces.tasks.async_update_fyle_credentials',
employee_info['data']['org']['id'], tokens['refresh_token']
)
fyle_rest_auth/helpers.py:163
async_update_user_settings_apicurrently hard-requiresdjango_q; if it’s missing,import_string('django_q.tasks.async_task')will abort the whole request. Since this block is an optional background update, catch ImportError and log + skip (or provide a non-django_qfallback).
if 'async_update_user_settings_api' in settings.FYLE_REST_AUTH_SETTINGS \
and settings.FYLE_REST_AUTH_SETTINGS['async_update_user_settings_api']:
async_task = import_string('django_q.tasks.async_task')
async_task(
'apps.orgs.tasks.async_update_fyle_credentials',
employee_info['data']['org']['id'], tokens['refresh_token']
)
fyle_rest_auth/helpers.py:151
- Same issue here: when
async_update_useris enabled butdjango_qisn’t installed, this ImportError causes refresh-token login to fail even though the async update is optional. Guard the import and fall back to the synchronous update instead of raising ValidationError.
if 'async_update_user' in settings.FYLE_REST_AUTH_SETTINGS:
if settings.FYLE_REST_AUTH_SETTINGS['async_update_user']:
async_task = import_string('django_q.tasks.async_task')
async_task(
'apps.workspaces.tasks.async_update_fyle_credentials',
employee_info['data']['org']['id'], tokens['refresh_token']
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
garvit568
approved these changes
Aug 5, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.