HomePostsProjects

Typing second-order decorators that may be called with and without arguments

September 17, 2022

Second-order decorators:

  • use bound generics to handle types
  • use overload types for each invocation to handle decorators that may be called with and without arguments
  • https://mypy.readthedocs.io/en/stable/generics.html#decorator-factories
  • https://github.com/python/mypy/issues/3360

Exclude coverage checks on overloaded typing stubs:

  • https://github.com/nedbat/coveragepy/issues/970

© 2025 Luke Miloszewski

Email AddressGitHubTwitter