forked from VimPlug/jedi
Fix ForeignKey issues with invalid values
This commit is contained in:
@@ -48,10 +48,11 @@ mapping = {
|
||||
|
||||
|
||||
def _infer_scalar_field(cls, field, field_tree_instance):
|
||||
if field_tree_instance.name.string_name not in mapping:
|
||||
try:
|
||||
module_name, attribute_name = mapping[field_tree_instance.name.string_name]
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
module_name, attribute_name = mapping[field_tree_instance.name.string_name]
|
||||
if module_name is None:
|
||||
module = cls.inference_state.builtins_module
|
||||
else:
|
||||
@@ -69,6 +70,7 @@ def _infer_field(cls, field):
|
||||
|
||||
if field_tree_instance.name.string_name == 'ForeignKey':
|
||||
if isinstance(field_tree_instance, TreeInstance):
|
||||
# TODO private access..
|
||||
argument_iterator = field_tree_instance._arguments.unpack()
|
||||
key, lazy_values = next(argument_iterator, (None, None))
|
||||
if key is None and lazy_values is not None:
|
||||
@@ -77,7 +79,7 @@ def _infer_field(cls, field):
|
||||
foreign_key_class_name = value.get_safe_value()
|
||||
for v in cls.parent_context.py__getattribute__(foreign_key_class_name):
|
||||
return DjangoModelField(v, field)
|
||||
else:
|
||||
elif value.is_class():
|
||||
return DjangoModelField(value, field)
|
||||
|
||||
debug.dbg('django plugin: fail to infer `%s` from class `%s`',
|
||||
|
||||
Reference in New Issue
Block a user