mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-08 19:01:27 +08:00
made code slightly more pytho2 friendly
This commit is contained in:
@@ -3,7 +3,11 @@ This module is not intended to be used in jedi, rather it will be fed to the
|
||||
jedi-parser to replace classes in the typing module
|
||||
"""
|
||||
|
||||
from collections import abc
|
||||
try:
|
||||
from collections import abc
|
||||
except ImportError:
|
||||
# python 2
|
||||
import collections as abc
|
||||
|
||||
|
||||
def factory(typing_name, indextype):
|
||||
|
||||
@@ -56,7 +56,7 @@ def _fix_forward_reference(evaluator, item, module):
|
||||
element.parent = module
|
||||
return evaluator.eval_element(element)
|
||||
else:
|
||||
return {item}
|
||||
return set([item])
|
||||
|
||||
|
||||
@memoize_default(None, evaluator_is_first_arg=True)
|
||||
@@ -95,7 +95,7 @@ def get_types_for_typing_module(evaluator, typ, trailer):
|
||||
# actually the PEP-0484 typing module and not some other
|
||||
indextypes = evaluator.eval_element(trailer.children[1])
|
||||
if not isinstance(indextypes, set):
|
||||
indextypes = {indextypes}
|
||||
indextypes = set([indextypes])
|
||||
|
||||
module = trailer.get_parent_until()
|
||||
dereferencedindextypes = set()
|
||||
@@ -109,9 +109,9 @@ def get_types_for_typing_module(evaluator, typ, trailer):
|
||||
factory = list(factories)[0]
|
||||
assert factory
|
||||
function_body_nodes = factory.children[4].children
|
||||
valid_classnames = {child.name.value
|
||||
for child in function_body_nodes
|
||||
if isinstance(child, tree.Class)}
|
||||
valid_classnames = set(child.name.value
|
||||
for child in function_body_nodes
|
||||
if isinstance(child, tree.Class))
|
||||
if typ.name.value not in valid_classnames:
|
||||
return None
|
||||
compiled_classname = compiled.create(evaluator, typ.name.value)
|
||||
|
||||
Reference in New Issue
Block a user