Creating Type Stubs for Scientific Python (Part 4)
The Story Thus Far Its been a while since the last post, mainly because I hit a speed bump along the way, which I have since addressed. It’s worth recapping what was covered before.
Scientific Python pacckages like matplotlib don’t have much in the way of inline type annotations, nor do they have good type stubs available, but those would be very useful to improve the experience using them in code editors they do have a standard form of docstrings, numpydoc format, and that includes parameter and return value descriptions that most of the time include descriptions of the types (albeit in an informal way) I decided to build a tool to extract these and try to convert them to formal type annotations and generate stubs the extraction part, and the ‘insert converted annotations in to make stubs’ part, are reasonably straightforward, thanks in particular to Instagram’s libCST library for concrete syntax tree visiting and transforming I write the extracted descriptions plus my best effort at turning these into formal types into ‘.