Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finalize type signatures and enforce for all future functions (#1061)
* Finalize type signatures and enforce for all future functions This commit adds the last few missing type hints (primarily the generators module) and switches the CI configuration over to enforce that the library is completely type hinted. This makes it a CI error if a function or method is added that doesn't include type hints. This is all built on the hard work of @IvanIsCoding who built up all the type hinting infrastructure and stub files for the majority of rustworkx. This is just the last piece to enforce the library is fully typed moving forward. Co-authored-by: Ivan Carvalho <[email protected]> * Fix lint * Add missing stubs and run on full package * Fix to_dot() and graphviz_draw() hints * Fix lint * Fix search function hints * Fix full package stubtest This commit fixes most of the package for stubtest to work. This primarily involves having the stubfiles match the package layout. Unfortunately this means we need to put the majority of the type hints in the stubfile for `rustworkx.rustworkx`. Having the stubfiles split up as before mypy complains that the module doesn't exist. For example, having the coloring functions in `rustworkx/coloring.pyi` causes a mypy error that `rustworkx.coloring` couldn't be imported. This causes the rustworkx.pyi file to be quite large, but I couldn't find a pattern to workaround this limitation. Aside from that a bunch of stubs needed to be updated as now that they're getting included in the stubtest run issues were caught. The one exception is the generators module where the custom `text_signature` set in the function definitions were incorrect and tripping up mypy, these were fixed by removing the `text_signature` fields. * Ignore matplotlib type checks * Add back type hints lost during rebase * Add stub file for matplotlib visualization * Bump mypy version used in tests * Add stub file for graphviz too * Fix last failure * Fix typo * Use typing_extensions for mpl_draw type hints * Add re-exports to root __init__.pyi This commit adds back the re-exports to the root `__init__.pyi` stub file. As was reported in #960 the manual re-exports are necessary to ensure that mypy can find symbols in the root of the package, where most people use them, instead of off the inner `rustworkx.rustworkx` module. * Add release note * Add type check ignore to mpl for 3.8 failures * Fix release note typo --------- Co-authored-by: Ivan Carvalho <[email protected]>
- Loading branch information