Make numpy dependency from types-networkx optional
I'm using networkx to implement NUMA affinity maps in a system management control plane.
Recently I added types-networkx and it brought numpy dependency as well, breaking some of our CI and deployments that previously did not use any "scientific" pacakges like numpy.
I'd like to reuse the pure graph algorithms only and do not use the numpy array conversion APIs. Could we make it an optional dependency?
https://github.com/python/typeshed/blob/main/stubs/networkx/METADATA.toml#L4
The upstream package also defines numpy as a part of optional dependencies: https://github.com/networkx/networkx/blob/da991effb0509d5ef59516c1b3c0848bb847c3b8/pyproject.toml#L38 https://github.com/networkx/networkx/blob/da991effb0509d5ef59516c1b3c0848bb847c3b8/pyproject.toml#L63 though the extra set name "default" in the context of "optional" looks weired to me...
If networkx is usable as a standalone package, we should indeed not depend on numpy, especially given the size and complexity of the numpy package.
It might be quite a bit of work, and we may loose on type safety in some places, but we could try to make numpy optional for types-networkx. By using protocols, and letting the type-checkers fallback to Any/Unknown with ignored import errors.