spherely
spherely copied to clipboard
Add script to generate the stub file
This is a draft for a script that can generate the spherely.pyi
stub file.
During the EuroSciPy 2024 sprint, I worked with @jorisvandenbossche on #43 . We realized that we need several different _VFunc_*
types to cover the different overloaded arguments for functions going forward. We tried a few different approaches to avoid too much boilerplate/copy-paste code, including ways of creating dynamic types but didn't find anything that was well supported by the type checkers.
Instead, the following script can automatically generate code for such classes. It works by looking a # /// Begin types
marker and lines defining which types should be added. For example, to create a type that takes 2 geography inputs, as well as an optional radius
parameter of type float
, we can add the specification line:
# - n_in=2, radius=float
Running the script will then update the code in-place between the # /// Begin types
and the corresponding # /// End types
marker. Any existing edits between those markers will be overwritten, but the rest of the file is left alone.