serhii.net

In the middle of the desert you can say anything you want

06 Jul 2022

Pycharm code code completion suggestions and references

Reminder of why people use IDEs

Was unhappy about the order of suggestions for completion in Pycharm, more current stuff I can remember than arguments to a function I don’t.

Started looking for ways to order them, but then realized that I ACTUALLY want documentation for the thing under the cursor - that I have in vim/jedi and use but somehow not in pycharm.

Code reference information | PyCharm:

  1. <Ctrl-Shift-I> does this “Quick definition”
  2. The “Ctrl-click” “go to source” bit - if you don’t click but just hover you also get a tooltip.

“View -> Quick type definition” exists too! Can be bound to a key, but available though the menu.

That menu has A LOT of stuff that is going to be transformative for the way I code. Describing here in full to remember it, it’s worth it.

My understanding is:

  • “Quick definition”: short “what” and the closest “where”
    • short “what”: “it’s a function: def ou()..”, “It’s a variable the function got through this part of the signature: a: str,
    • <C-S-i> by default
  • “Quick documentation” - a bit of everything
    • signature, docstring, everything I usually need
    • <Alt-K> for me, default <Ctrl-P>,
    • if pressed twice opens a separate static window that shows the documentation of everything under the cursor as it moves!
  • “Type info” - “it’s a str!”
    • Tells you the type information - prolly type hints but not necessarily
    • <Alt-P> for me, default <Ctrl-Shift-P>
  • “Quick type definition”: Function or classes signatures
    • This thing is a duck. Ducks are birds that ….. If the duck is a str - well now I know that a str has a long definition. No default shortcut.
  • “Context info” - info about current thing from off-screen
    • <Alt-q>
    • First the name of the function being edited, then the name of the class it’s in, etc.
    • Repeat calls make it go higher

Changes to my shortcuts

  • <Alt-K> is now quick documentation
  • <Alt-P> is now type info

Onwards!

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus