mirror of
https://github.com/davidhalter/jedi.git
synced 2026-09-17 19:23:14 +08:00
Avoid AttributeErrors for generics when a module is passed
This commit is contained in:
@@ -217,18 +217,19 @@ class GenericClass(ClassMixin, DefineGenericBase):
|
|||||||
# Note: we need to handle the MRO _in order_, so we need to extract
|
# Note: we need to handle the MRO _in order_, so we need to extract
|
||||||
# the elements from the set first, then handle them, even if we put
|
# the elements from the set first, then handle them, even if we put
|
||||||
# them back in a set afterwards.
|
# them back in a set afterwards.
|
||||||
for element in value_set:
|
for py_class in value_set:
|
||||||
if element.api_type == u'function':
|
if not is_class_value:
|
||||||
# Functions & methods don't have an MRO and we're not
|
if py_class.is_instance():
|
||||||
|
py_class = py_class.get_annotated_class_object()
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if py_class.api_type != u'class':
|
||||||
|
# Functions & modules don't have an MRO and we're not
|
||||||
# expecting a Callable (those are handled separately within
|
# expecting a Callable (those are handled separately within
|
||||||
# TypingClassValueWithIndex).
|
# TypingClassValueWithIndex).
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if element.is_instance():
|
|
||||||
py_class = element.get_annotated_class_object()
|
|
||||||
else:
|
|
||||||
py_class = element
|
|
||||||
|
|
||||||
for parent_class in py_class.py__mro__():
|
for parent_class in py_class.py__mro__():
|
||||||
class_name = parent_class.py__name__()
|
class_name = parent_class.py__name__()
|
||||||
if annotation_name == class_name:
|
if annotation_name == class_name:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# python >= 3.4
|
# python >= 3.4
|
||||||
|
import typing
|
||||||
from typing import (
|
from typing import (
|
||||||
Callable,
|
Callable,
|
||||||
Dict,
|
Dict,
|
||||||
@@ -51,6 +52,10 @@ x1 = list_t_to_list_t(foo)[0]
|
|||||||
#?
|
#?
|
||||||
x1
|
x1
|
||||||
|
|
||||||
|
x1 = list_t_to_list_t(typing)[0]
|
||||||
|
#?
|
||||||
|
x1
|
||||||
|
|
||||||
x2 = list_t_to_list_t(tpl)[0]
|
x2 = list_t_to_list_t(tpl)[0]
|
||||||
#?
|
#?
|
||||||
x2
|
x2
|
||||||
|
|||||||
Reference in New Issue
Block a user