Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix instance docstring #942

Merged
merged 1 commit into from
Jul 13, 2017
Merged

Conversation

micbou
Copy link
Contributor

@micbou micbou commented Jul 13, 2017

Jedi always returns an empty docstring for an instance. For example, the following code:

import jedi

source = """
class TestClass():
    '''Docstring of `TestClass`.'''
tc = TestClass()
tc"""

definitions = jedi.Script(source).goto_definitions()
print(definitions[0].docstring())

returns nothing while it should output Docstring of `TestClass`.. It's a regression introduced by commit 7ca6257.

This PR fixes the regression and add two docstring tests: one with a class and another with an instance.


This change is Reviewable

@@ -24,6 +24,7 @@ def __init__(self, evaluator, parent_context, class_context, var_args):
super(AbstractInstanceContext, self).__init__(evaluator, parent_context)
# Generated instances are classes that are just generated by self
# (No var_args) used.
self.tree_node = class_context.tree_node
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, thanks for the test and fix. However I'm not sure I like this here. If anything I would have probably moved that assignment to jedi.evaluate.instance.TreeInstance. Would that make sense for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I moved it to TreeInstance.

@davidhalter davidhalter merged commit 175e572 into davidhalter:dev Jul 13, 2017
@davidhalter
Copy link
Owner

Thanks man, good stuff!

@micbou micbou deleted the fix-instance-docstring branch July 14, 2017 00:27
zzbot added a commit to vheon/JediHTTP that referenced this pull request Aug 20, 2017
[READY] Update Jedi to latest commit

Jedi master branch now includes davidhalter/jedi#941 and davidhalter/jedi#942 fixes, and successfully passes ycmd tests.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/vheon/jedihttp/36)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants