~/talk

Building a Python Code Completer

Talkat PyCon US 2022 · 2022-04-27..05-03· [python]
slides:none on file

Claim: a working Python code completer is simple to build and can be demoed live. Uses Python's ast.parse to replace the cursor with a sentinel, walks the AST to collect scope (assignments and function args), and returns contextually appropriate names; a minimal version is about 10 lines and runs in roughly five minutes. Notes limitations: CPython ast has no error recovery so completion relies on hacks or alternative parsers like Sculpt parser (used in Anvil) or jedi/tree-sitter, and types from remote APIs remain hard.

AI-written summary · about

  1. 0:00Start
  2. 1:46Why Code Completion?
  3. 4:59Parsing
  4. 6:08Grammar file
  5. 7:35The "ast" module
  6. 18:11Simple extensions
  7. 19:12Backward reference
  8. 21:09Error recovery
  9. 21:50Alternative Parsers
  10. 25:51What Have We Learned?
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.