You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the GitHub search to find a similar question and didn't find it.
I searched the Typer documentation, with the integrated search.
I already searched in Google "How to X in Typer" and didn't find any information.
I already read and followed all the tutorials in the docs and didn't find an answer.
I already checked if it is not related to Typer but to Click.
Commit to Help
I commit to help with one of those options 👆
Example Code
# Would be great if I could do something like thisfromtyper.fast.precompletehookimportis_completion, get_completion_data, do_completion# top of file# fast return if no changesifis_completion():
ifno_changes_to_script():
completion=read_completion_data_from_disk()
return# normal scriptimporttyper
...
defmain():
print("Hello World")
if__name__=="__main__":
ifis_completion():
completion=get_completion_data(main)
save_completion_with_script_hash_to_disk(completion)
do_completion(completion)
typer.run(main)
Description
Typer takes ~ 500ms for autocomplete on my m1 macbook. Pythong can run in 50 ms.
Would be great if we could save the completion and return a cached copy. I'm confident :) this needs custom business logic, so will likely need to expose hooks to let developers customize.
I did something like this for another python script that reflects on typer commands before returning completion for another tool, using a cache gets me from 500ms => 50ms:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
Typer takes ~ 500ms for autocomplete on my m1 macbook. Pythong can run in 50 ms.
Would be great if we could save the completion and return a cached copy. I'm confident :) this needs custom business logic, so will likely need to expose hooks to let developers customize.
I did something like this for another python script that reflects on typer commands before returning completion for another tool, using a cache gets me from 500ms => 50ms:
Look at y.py in this diff:
idvorkin/Settings@1ee830a#diff-d21acc80b353a7c602db52322ed4f6704b1d6a088176bd93f61af5e819a3489b
I was trying to grock how to do this, but seems pretty complex from reading: #951 (comment)
Operating System
macOS
Operating System Details
No response
Typer Version
Latest
Python Version
Latest
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions