Django-plugin related code is removed from stdlib-plugin.

This commit is contained in:
ANtlord
2020-01-21 21:21:43 +02:00
parent 7287d67e7a
commit 2a86f7d82f
3 changed files with 15 additions and 10 deletions

View File

@@ -80,3 +80,16 @@ def _infer_field(cls, field):
return DjangoModelField(value, field).name return DjangoModelField(value, field).name
raise Exception('Should be handled') raise Exception('Should be handled')
def get_metaclass_filters(func):
def wrapper(cls, metaclasses):
for metaclass in metaclasses:
if metaclass.py__name__() == 'ModelBase' \
and metaclass.get_root_context().py__name__() == 'django.db.models.base':
django_dict_filter = new_dict_filter(cls)
if django_dict_filter is not None:
return django_dict_filter
return func(cls, metaclasses)
return wrapper

View File

@@ -4,7 +4,8 @@ This is not a plugin, this is just the place were plugins are registered.
from jedi.plugins import stdlib from jedi.plugins import stdlib
from jedi.plugins import flask from jedi.plugins import flask
from jedi.plugins import django
from jedi.plugins import plugin_manager from jedi.plugins import plugin_manager
plugin_manager.register(stdlib, flask) plugin_manager.register(stdlib, flask, django)

View File

@@ -35,8 +35,6 @@ from jedi.inference.filters import AttributeOverwrite, publish_method, \
ParserTreeFilter, DictFilter ParserTreeFilter, DictFilter
from jedi.inference.signature import AbstractSignature, SignatureWrapper from jedi.inference.signature import AbstractSignature, SignatureWrapper
from . import django
# Copied from Python 3.6's stdlib. # Copied from Python 3.6's stdlib.
_NAMEDTUPLE_CLASS_TEMPLATE = """\ _NAMEDTUPLE_CLASS_TEMPLATE = """\
@@ -792,13 +790,6 @@ def get_metaclass_filters(func):
return [DictFilter({ return [DictFilter({
name.string_name: EnumInstance(cls, name).name for name in filter_.values() name.string_name: EnumInstance(cls, name).name for name in filter_.values()
})] })]
if metaclass.py__name__() == 'ModelBase' \
and metaclass.get_root_context().py__name__() == 'django.db.models.base':
django_dict_filter = django.new_dict_filter(cls)
if django_dict_filter is not None:
return django_dict_filter
return func(cls, metaclasses) return func(cls, metaclasses)
return wrapper return wrapper