mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
Make sure docstrings can always be inferred for builtins modules, fixes #1432
This commit is contained in:
@@ -45,7 +45,16 @@ def _limit_value_infers(func):
|
|||||||
inference_state = context.inference_state
|
inference_state = context.inference_state
|
||||||
try:
|
try:
|
||||||
inference_state.inferred_element_counts[n] += 1
|
inference_state.inferred_element_counts[n] += 1
|
||||||
if inference_state.inferred_element_counts[n] > 300:
|
maximum = 300
|
||||||
|
if context.parent_context is None \
|
||||||
|
and context.get_value() is inference_state.builtins_module:
|
||||||
|
# Builtins should have a more generous inference limit.
|
||||||
|
# It is important that builtins can be executed, otherwise some
|
||||||
|
# functions that depend on certain builtins features would be
|
||||||
|
# broken, see e.g. GH #1432
|
||||||
|
maximum *= 100
|
||||||
|
|
||||||
|
if inference_state.inferred_element_counts[n] > maximum:
|
||||||
debug.warning('In value %s there were too many inferences.', n)
|
debug.warning('In value %s there were too many inferences.', n)
|
||||||
return NO_VALUES
|
return NO_VALUES
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|||||||
@@ -518,7 +518,7 @@ class InstanceClassFilter(AbstractFilter):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s for %s>' % (self.__class__.__name__, self._class_filter.context)
|
return '<%s for %s>' % (self.__class__.__name__, self._class_filter)
|
||||||
|
|
||||||
|
|
||||||
class SelfAttributeFilter(ClassFilter):
|
class SelfAttributeFilter(ClassFilter):
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import pytest
|
|||||||
from pytest import raises
|
from pytest import raises
|
||||||
from parso import cache
|
from parso import cache
|
||||||
|
|
||||||
|
from jedi._compatibility import unicode
|
||||||
from jedi import preload_module
|
from jedi import preload_module
|
||||||
from jedi.inference.gradual import typeshed
|
from jedi.inference.gradual import typeshed
|
||||||
|
|
||||||
@@ -311,3 +312,8 @@ def test_goto_follow_builtin_imports(Script):
|
|||||||
assert d.in_builtin_module() is True
|
assert d.in_builtin_module() is True
|
||||||
d, = s.goto_assignments(follow_imports=True, follow_builtin_imports=True)
|
d, = s.goto_assignments(follow_imports=True, follow_builtin_imports=True)
|
||||||
assert d.in_builtin_module() is True
|
assert d.in_builtin_module() is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_docstrings_for_completions(Script):
|
||||||
|
for c in Script('').completions():
|
||||||
|
assert isinstance(c.docstring(), (str, unicode))
|
||||||
|
|||||||
Reference in New Issue
Block a user