This PR adds precise typing overloads to grass.temporal.factory's dataset_factory function. This enables type checkers like mypy or Pyright for example to understand the returned class from the string passed as the type argument. Combined with returning directly the dataset, this function is almost completely typed.
For example, in grass.temporal.univar_statistics, the IDE can show what overload dataset_factory is using, and the type of sp can be inferred to SpaceTimeVectorDataset
Also, it improves the sphinx generated docs. Our current sphinx build process can understand and use the typing information, plus show the overloads too, linking to classes in our docs when appropriate. Below are before/after screenshots. Note that with trial-and-error, the non-overloaded (implementation) function signature isn't shown anymore, that's why a more generic signature was used
Before:
After:
In a previous iteration, I tried using a python typing stub file, a .pyi file, but even though the IDE experience was the same, since it wasn't installed like other python files, the sphinx doc generation didn't show the improvements like on the screenshots. I didn't try editing the makefiles to be able to copy pyi files too in the install location to see if it would have the same effect.
This PR adds precise typing overloads to grass.temporal.factory's dataset_factory function. This enables type checkers like mypy or Pyright for example to understand the returned class from the string passed as the type argument. Combined with returning directly the dataset, this function is almost completely typed.
For example, in grass.temporal.univar_statistics, the IDE can show what overload dataset_factory is using, and the type of
sp
can be inferred toSpaceTimeVectorDataset
Also, it improves the sphinx generated docs. Our current sphinx build process can understand and use the typing information, plus show the overloads too, linking to classes in our docs when appropriate. Below are before/after screenshots. Note that with trial-and-error, the non-overloaded (implementation) function signature isn't shown anymore, that's why a more generic signature was used
Before: After:
In a previous iteration, I tried using a python typing stub file, a .pyi file, but even though the IDE experience was the same, since it wasn't installed like other python files, the sphinx doc generation didn't show the improvements like on the screenshots. I didn't try editing the makefiles to be able to copy pyi files too in the install location to see if it would have the same effect.