-
-
Notifications
You must be signed in to change notification settings - Fork 511
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
Type hints for return values #990
Comments
Probably related, and if so, then it looks like a regression. I tried the examples in https://jedi.readthedocs.io/en/latest/docs/usage.html#tab-completion-in-the-python-shell and they don't work. |
Which examples? The only test example works for me in IPython (which is powered by Jedi). It doesn't work for me in the shell though. It's probably some setup fail. IMO it's not related. You may open a new issue. |
I just found that openSUSE provides it's own startup scripts for python and that might be the reason for my problems. |
This issue was raised in #990. The completer was never used in Python3.4+, because it was overwritten by Python's completer. Oddly enough it has always worked in Python2.7/3.3. The documentation was also slightly modified. os.path.join was always a complex beast.
@etam I realized you are right. Please test again with current master. Tab completion in the Python shell did really not work in 3.4+. I tested it in 2.7 and 3.3 a long time ago and don't really use it much. Unfortunately it's not something I can test with regression tests. So it might just fail again in Python 4.x or whatever. Please note that this has nothing to do with the original issue. |
@davidhalter It works, thanks! |
Any update on the original issue here? I see this is marked as a discussion, is it not a regression? Jedi is the upstream dependency for vscode's python language service, so a lot of people could benefit from a fix/feature here. Right now the workaround is we need to cmd+click the function to go to its definition and see the return type, instead of getting it from the intellisense. |
There's no update. I'm working on typeshed (#1096). Once that's done, this might or might not be fixed, because it involves so many type hints. |
@aaltat I just realized that there might be an easier fix for your problem: Why don't you use a return annotation? If it really needs to work with Python 2 code you can just use:
I actually always thought that your issue was that it was not working at all. However now that I was actually reading your issue exactly (sorry - stupid me), I realized that this was probably your issue. The above is what PEP 484 suggest for your problem: https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code Please let me know if this doesn't solve your problem. I will reopen if it's not good enough. |
Ok, did not see that such thing exists. Thanks for the tip. |
If have method which returns an object which Jedi is not able to resolve, is it possible define the type of the returned object in the method which returns it. Example if cache where I can return example WebDriver instances, I know that this works:
But if I use the
get_driver
method in multiple places in my code, in each place, I must add comment:# type: selenium.webdriver.remote.webdriver.WebDriver
comment. Which is quite annoying to remember to copy/paste. Also if the import is quite long, then it easily exceeds the maximum line length. Is there a an way to define the return type in the method which actually returning the object. I did try this:and this:
but the completion did not work. Would there be a way to get the completion working by defining something in the method side which is returning something?
The text was updated successfully, but these errors were encountered: