mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Fix a bug with version_info, fixes #1477
This commit is contained in:
@@ -634,7 +634,7 @@ class StubName(StubNameMixin, TreeNameDefinition):
|
|||||||
inferred = super(StubName, self).infer()
|
inferred = super(StubName, self).infer()
|
||||||
if self.string_name == 'version_info' and self.get_root_context().py__name__() == 'sys':
|
if self.string_name == 'version_info' and self.get_root_context().py__name__() == 'sys':
|
||||||
from jedi.inference.gradual.stub_value import VersionInfo
|
from jedi.inference.gradual.stub_value import VersionInfo
|
||||||
return [VersionInfo(c) for c in inferred]
|
return ValueSet(VersionInfo(c) for c in inferred)
|
||||||
return inferred
|
return inferred
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -75,3 +75,17 @@ def test_attribute_docstrings(goto_or_help, expected_doc, to_execute):
|
|||||||
|
|
||||||
d, = goto_or_help(code + to_execute)
|
d, = goto_or_help(code + to_execute)
|
||||||
assert d.docstring() == expected_doc
|
assert d.docstring() == expected_doc
|
||||||
|
|
||||||
|
|
||||||
|
def test_version_info(Script):
|
||||||
|
"""
|
||||||
|
Version info is a bit special, because it needs to be fast for some ifs, so
|
||||||
|
it's a special object that we have to check.
|
||||||
|
"""
|
||||||
|
s = Script(dedent("""\
|
||||||
|
import sys
|
||||||
|
|
||||||
|
sys.version_info"""))
|
||||||
|
|
||||||
|
c, = s.completions()
|
||||||
|
assert c.docstring() == 'sys.version_info\n\nVersion information as a named tuple.'
|
||||||
|
|||||||
Reference in New Issue
Block a user