forked from VimPlug/jedi
Small improvements to generator/async completions
This commit is contained in:
@@ -139,6 +139,12 @@ class InferenceState:
|
|||||||
typing_module, = self.import_module(('typing',))
|
typing_module, = self.import_module(('typing',))
|
||||||
return typing_module
|
return typing_module
|
||||||
|
|
||||||
|
@property
|
||||||
|
@inference_state_function_cache()
|
||||||
|
def types_module(self):
|
||||||
|
typing_module, = self.import_module(('types',))
|
||||||
|
return typing_module
|
||||||
|
|
||||||
def reset_recursion_limitations(self):
|
def reset_recursion_limitations(self):
|
||||||
self.recursion_detector = recursion.RecursionDetector()
|
self.recursion_detector = recursion.RecursionDetector()
|
||||||
self.execution_recursion_detector = recursion.ExecutionRecursionDetector(self)
|
self.execution_recursion_detector = recursion.ExecutionRecursionDetector(self)
|
||||||
|
|||||||
@@ -340,10 +340,10 @@ class BaseFunctionExecutionContext(ValueContext, TreeContextMixin):
|
|||||||
for c in async_generator_classes
|
for c in async_generator_classes
|
||||||
).execute_annotation(None)
|
).execute_annotation(None)
|
||||||
else:
|
else:
|
||||||
async_classes = inference_state.typing_module.py__getattribute__('Coroutine')
|
async_classes = inference_state.types_module.py__getattribute__('CoroutineType')
|
||||||
return_values = self.get_return_values()
|
return_values = self.get_return_values()
|
||||||
# Only the first generic is relevant.
|
# Only the first generic is relevant.
|
||||||
generics = (return_values.py__class__(), NO_VALUES, NO_VALUES)
|
generics = (NO_VALUES, NO_VALUES, return_values.py__class__())
|
||||||
return ValueSet(
|
return ValueSet(
|
||||||
GenericClass(c, TupleGenericManager(generics)) for c in async_classes
|
GenericClass(c, TupleGenericManager(generics)) for c in async_classes
|
||||||
).execute_annotation(None)
|
).execute_annotation(None)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class GeneratorBase(LazyAttributeOverwrite, IterableMixin):
|
|||||||
return instance
|
return instance
|
||||||
|
|
||||||
def _get_cls(self):
|
def _get_cls(self):
|
||||||
generator, = self.inference_state.typing_module.py__getattribute__('Generator')
|
generator, = self.inference_state.types_module.py__getattribute__('GeneratorType')
|
||||||
return generator
|
return generator
|
||||||
|
|
||||||
def py__bool__(self):
|
def py__bool__(self):
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ else
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
pass
|
pass
|
||||||
#? ['except', 'Exception']
|
#? ['except', 'Exception', 'ExceptionGroup']
|
||||||
except
|
except
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pass
|
pass
|
||||||
#? 6 ['except', 'Exception']
|
#? 6 ['except', 'Exception', 'ExceptionGroup']
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
#? ['finally']
|
#? ['finally']
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Fr'{Foo.bar'
|
|||||||
Fr'{Foo.bar
|
Fr'{Foo.bar
|
||||||
#? ['bar']
|
#? ['bar']
|
||||||
Fr'{Foo.bar
|
Fr'{Foo.bar
|
||||||
#? ['Exception']
|
#? ['Exception', 'ExceptionGroup']
|
||||||
F"{Excepti
|
F"{Excepti
|
||||||
|
|
||||||
#? 8 Foo
|
#? 8 Foo
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#? ['raise']
|
#? ['raise']
|
||||||
raise
|
raise
|
||||||
|
|
||||||
#? ['Exception']
|
#? ['Exception', 'ExceptionGroup']
|
||||||
except
|
except
|
||||||
|
|
||||||
#? []
|
#? []
|
||||||
|
|||||||
@@ -49,11 +49,7 @@ def iterators(ps: Iterable[int], qs: Iterator[str], rs:
|
|||||||
a, b = ps
|
a, b = ps
|
||||||
#? int()
|
#? int()
|
||||||
a
|
a
|
||||||
##? int() --- TODO fix support for tuple assignment
|
#? int()
|
||||||
# https://github.com/davidhalter/jedi/pull/663#issuecomment-172317854
|
|
||||||
# test below is just to make sure that in case it gets fixed by accident
|
|
||||||
# these tests will be fixed as well the way they should be
|
|
||||||
#?
|
|
||||||
b
|
b
|
||||||
|
|
||||||
for q in qs:
|
for q in qs:
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ from datetime import datetime, timedelta
|
|||||||
(datetime - timedelta)
|
(datetime - timedelta)
|
||||||
#? datetime()
|
#? datetime()
|
||||||
(datetime() - timedelta())
|
(datetime() - timedelta())
|
||||||
#? timedelta()
|
#? timedelta() datetime()
|
||||||
(datetime() - datetime())
|
(datetime() - datetime())
|
||||||
#? timedelta()
|
#? timedelta()
|
||||||
(timedelta() - datetime())
|
(timedelta() - datetime())
|
||||||
|
|||||||
@@ -389,6 +389,6 @@ if False:
|
|||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
#< (1, 21), (0, 7), ('socket', ..., 6), ('stub:socket', ..., 4), ('imports', ..., 7)
|
#< (1, 21), (0, 7), ('socket', ..., 6), ('stub:socket', ..., 6), ('imports', ..., 7)
|
||||||
socket.SocketIO
|
socket.SocketIO
|
||||||
some_socket = socket.SocketIO()
|
some_socket = socket.SocketIO()
|
||||||
|
|||||||
Reference in New Issue
Block a user