Skip to content

package import inappropriate #343

@kiran1415

Description

@kiran1415

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions