~/talk

Enhancing Decorators with Type Annotations: Techniques and Best Practices

Talkat PyCon US 2024 · 2024-05-15..05-23· [python, typescript]
slides:none on file

Shows concrete type-annotation patterns that make decorators verifiable: examples use ParamSpec, Protocol, Concatenate, TypeVarTuple and the new Python 3.12 type parameter syntax. Builds a logger-decorator that injects a remote-Logger into HTTP client callables, sends JSON logs to a server, and returns the original response; example code is uploaded. Demonstrates that mypy (older versions) misses some new syntax while pyright/pyre-style checkers catch misuse, and claims these hints find call-site errors before runtime.

AI-written summary · about

  1. 0:00Decorators and type annotations
  2. 1:08Decorator typing challenges
  3. 3:00Python decorators basics
  4. 4:00Logging decorator for HTTP
  5. 7:34Typing protocols for interfaces
  6. 9:43ParamSpec for argument hints
  7. 11:31Concatenate for signatures
  8. 14:00Python 3.12 new types
  9. 15:50Enhanced logging decorator
  10. 18:29TypeVarTuple for variable-length argument handling
  11. 20:23Type checking tools
~/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.