Skip to content

Python Stubs

MatejKastak edited this page Mar 3, 2023 · 3 revisions
  • type definitions for Python are stored in src/python/typings/__init__.pyi
  • they are included in the distribution package
  • bindings were initially generated using stubgen tool
  • stubgen -m yaramod
  • it looks like that we can also generate stubs using pyright
  • pyright --createstub yaramod
  • comparing the output of both tools, I think I like the stubgen more

How to update bindings?

  • typing stubs must be updated manually
  • you can use stubgen or pyright to generate a reference file
  • from this file you can then adopt some relevant parts, but the generated output should not be used directly

Tests

  • currently we have a test setup that ensures that the file with stubs is valid
  • however, it does not ensure that the stubs are correct

Clone this wiki locally