~/talk

Reformating your code without AI - let's see how a formatter works

slides:none on file

Explains how autoformatters parse and rewrite Python using a concrete syntax tree via libcst, showing that CST retains whitespace, comments and commas so formatters can change layout reliably. Demonstrates using match/matcher patterns and a Transformer to traverse the huge CST, flip boolean literals across a module, and emit updated source with the .code attribute. Works on small examples; live CST outputs very large trees and is practical for prototyping though heavy for massive codebases.

AI-written summary · about

  1. 0:00Introduction and self-introduction
  2. 1:52Why use code formatters
  3. 2:54Understanding Python AST basics
  4. 4:40Abstract vs concrete syntax trees
  5. 8:11Why formatters need CST details
  6. 10:16Introducing libCST for formatting
  7. 13:26Matching patterns with libCST
  8. 15:12Visitors for tree traversal
  9. 17:18Example of visitor pattern
  10. 18:22Collecting typing annotations
  11. 20:27Transformers for code modification
  12. 21:11Visitors vs Transformers
  13. 21:53Typing Transformer example
  14. 23:37Generating source code from AST
  15. 24:19Building a Boolean inverter Transformer
  16. 25:22Flipping true and false values
  17. 26:46Benefits of custom Transformers
  18. 27:07Conclusion and key takeaways
  19. 27:49OpenSSF event announcement
  20. 28:51Q&A on libCST and formatters
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 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
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
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.