Answer the question
In order to leave comments, you need to log in
Pycharm 4 and django-oscar incompatibility?
The problem is specific and only concerns the Pycharm 4 bundle and the django-oscar project. django-oscar has the get_classes()
function :
def get_classes(module_label, classnames):
...
oscar_module_label = "oscar.apps.%s" % module_label
oscar_module = _import_module(oscar_module_label, classnames)
installed_apps_entry, app_name = _find_installed_apps_entry(module_label)
if installed_apps_entry.startswith('oscar.apps.'):
# The entry is obviously an Oscar one, we don't import again
local_module = None
else:
# Attempt to import the classes from the local module
# e.g. 'yourproject.dashboard.catalogue.forms'
sub_module = module_label.replace(app_name, '')
local_module_label = installed_apps_entry + sub_module
local_module = _import_module(local_module_label, classnames)
if oscar_module is local_module is None:
# This intentionally doesn't raise an ImportError, because ImportError
# can get masked in complex circular import scenarios.
raise ModuleNotFoundError(
"The module with label '%s' could not be imported. This either"
"means that it indeed does not exist, or you might have a problem"
" with a circular import." % module_label
)
# return imported classes, giving preference to ones from the local package
return _pluck_classes([local_module, oscar_module], classnames)
def _import_module(module_label, classnames):
try:
return __import__(module_label, fromlist=classnames)
except ImportError:
__, __, exc_traceback = sys.exc_info()
frames = traceback.extract_tb(exc_traceback)
if len(frames) > 1:
raise
my_class_1, my_class_2 = get_classes('myapp.mymodule', ['MyClass1', 'MyClass2'])
analogouslyfrom path_to_myapp.myapp.mymodule import MyClass1 as my_class_1
from path_to_myapp.myapp.mymodule import MyClass2 as my_class_2
__, __, exc_traceback = sys.exc_info()
frames = traceback.extract_tb(exc_traceback)
if len(frames) > 1:
raise
frames = [
('/home/dfdf/.virtualenvs/myenv/local/lib/python2.7/site-packages/oscar/core/loading.py', 159, '_import_module', 'return __import__(module_label, fromlist=classnames)'),
('/opt/pycharm-4.0/helpers/pydev/_pydev_imps/_pydev_pluginbase.py', 449, 'plugin_import', 'fromlist, level)')]
if len(frames) > 1:
if len(frames) > 2:
Answer the question
In order to leave comments, you need to log in
Once the sources are open, you can fork and add the change there. In addition, you can make a pull request with a description of this problem. I guess the app developers will be better able to comment on this.
You can also write to Pycharm support , but you need to keep in mind that the answer will not be soon)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question