Skip to content
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

package import inappropriate #343

Open
kiran1415 opened this issue Aug 28, 2023 · 0 comments
Open

package import inappropriate #343

kiran1415 opened this issue Aug 28, 2023 · 0 comments

Comments

@kiran1415
Copy link

Few imports have been made under a condition, but they are used anywhere in the views file. If the condition is not satisfied, it will throw an error, such as "variable is not defined."

notesapi/v1/views.py (line 18 to 30)

if not settings.ES_DISABLED:
    from elasticsearch_dsl import Search
    from elasticsearch_dsl.connections import connections
    from django_elasticsearch_dsl_drf.filter_backends import DefaultOrderingFilterBackend, HighlightBackend
    from django_elasticsearch_dsl_drf.constants import (
        LOOKUP_FILTER_TERM,
        LOOKUP_QUERY_IN,
        SEPARATOR_LOOKUP_COMPLEX_VALUE,
    )
    from notesapi.v1.search_indexes.paginators import NotesPagination as ESNotesPagination
    from notesapi.v1.search_indexes.backends import CompoundSearchFilterBackend, FilteringFilterBackend
    from notesapi.v1.search_indexes.serializers import NoteDocumentSerializer as NotesElasticSearchSerializer

but used anywhere without any conditions.
example LOOKUP_FILTER_TERM has been imported under ES_DISABLED condition but used without any prior condition.
in this, if we disable the ES_DISABLED = True then the project will throw errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant