Hi, I'm just getting started with Pythonista and I have a basic question on autocompletion:
If I do the following, either in the console or an editor window:
obj = MyObject()
Then when I type "obj." it will offer to autocomplete with the members of MyObject. But if I do this:
def foo(obj: MyObject):
... Here, "obj." does not autocomplete.
I'm used to using Pycharm which will autocomplete if you give it type hints like in the declaration above, so I'm just wondering if I'm missing something simple to get Pythonista to do the same thing?
dgelessus last edited by
Pythonista uses a library called
jedito get autocompletion suggestions in the editor. Most likely it doesn't support Python 3 type annotations and ignores them. I don't think there's another way to tell jedi "this variable has this type", so I think for now you'll have to do without autocompletion for function arguments.
Thanks!! Although now I'm more curious because after a little searching I found this:
Which seems to say that PEP 484 type hinting works. But now that I know about
jedi, I'll go back and play with it some more to see if I can get it to work with some other examples. Maybe I'm doing something wrong with my type hinting.
dgelessus last edited by
If it matters, Pythonista uses version 0.9.0 of jedi (see
jedi.__version__), and the latest version is 0.10.0.
That could be it too! It's weird, I can get it to work perfectly sometimes but not others. It might have to do with MyObject being defined in the same file versus a separate file. I'm going to keep experimenting ... If I figure out something reproducible I'll post it. Thanks again for the info!
JonB last edited by
One factor, I am not sure how the path is set for jedi -- and by default in pythonista, the current folder is NOT on sys.path, until you run a script in that folder. So, it might not be able to find your class if the external file is not explictly on sys.path.
frank last edited by frank
Ah!!! That did it! I switched over to the console, did os.chdir() to get to the correct path and did sys.path.append(os.getcwd()) and full completions are working now. Thank you!!
I'm not sure WHY the folder was not already in sys.path since I have clicked the Run button many times thinking that could be what was needed. But this workaround is perfect at any rate!
[I posted a follow up with what appeared to be a bug but I think I had a typo in my sample code because everything is working just fine now.]
This post is deleted!