1from jet_bridge_base import settings2
3VERSION = '1.9.3'
15from jet_bridge_base.filters.model_search import search_queryset
16from jet_bridge_base.models.model_relation_override import ModelRelationOverrideModel
17from jet_bridge_base.serializers.model import get_model_serializer
18from jet_bridge_base.serializers.model_serializer import get_column_data_type 19from jet_bridge_base.store import store
20from jet_bridge_base.utils.common import get_set_first, any_type_sorter, unique, flatten
21from jet_bridge_base.utils.gql import RawScalar
9from jet_bridge_base.automap import automap_base
10from jet_bridge_base.db import get_mapped_base, get_engine, load_mapped_base, get_request_connection, get_table_name
11from jet_bridge_base.filters import lookups
12from jet_bridge_base.filters.filter import safe_array, EMPTY_VALUES 13from jet_bridge_base.filters.filter_for_dbfield import filter_for_data_type
14from jet_bridge_base.filters.model_group import get_query_func_by_name
15from jet_bridge_base.filters.model_search import search_queryset
4from jet_bridge_base.utils.classes import is_instance_or_subclass
5from jet_bridge_base.utils.queryset import get_session_engine
6from sqlalchemy import Unicode, and_, or_
7from sqlalchemy.dialects.postgresql import ENUM, JSONB, array 8from sqlalchemy.sql import sqltypes
9from six import string_types
10
16from jet_bridge_base.filters.filter import EMPTY_VALUES, safe_array
17from jet_bridge_base.filters.model_group import get_query_func_by_name, get_query_lookup_func_by_name
18from jet_bridge_base.filters.filter_for_dbfield import filter_for_data_type
19from jet_bridge_base.serializers.model_serializer import get_column_data_type 20from jet_bridge_base.serializers.serializer import Serializer
21from jet_bridge_base.utils.db_types import map_to_sql_type, sql_to_map_type
22from jet_bridge_base.utils.queryset import get_session_engine, apply_session_timezone
An object has been imported but is not used anywhere in the file. It should either be used or the import should be removed.
import os
def example():
print("This snippet is not using the `os` import anywhere.")
def example():
print("This looks good now!")
One major reason why this issue can cause confusion is when it's raised for imports that are meant to be exported, for use in other places.
For example, consider this file, mypackage/__init__.py
:
from mypackage.foo import is_foo
from mypackage.bar import bar_function
This is a very common pattern to export common functionality from modules, to
the top level of a package. But there is a major problem with this approach.
Consider this file, mypackage/foo.py
:
import os
def is_foo(item):
return os.path.exists(item)
Since os
is imported inside foo.py
, you can actually do this:
>>> from mypackage.foo import os
Although weird, Python automatically exports all imports in a file. In practice however, it is ill-advised to rely on this behaviour.
If you want to explicitly export an imported item in a file, add it to the
special variable named __all__
:
from mypackage.foo import is_foo
from mypackage.bar import bar_function
__all__ = ['is_foo', 'bar_function'] # Notice that these are strings!
DeepSource won't raise an issue if the imported item is present in __all__
.