TYP: check typings with pyright
small followup to #44233
Thanks @twoertwein

Any changes needed for the pre-commit check? Do you think it makes sense to replace 

```py
numba = import_optional_dependency("numa")
```

with

```py
import_optional_dependency("numa")
import numba
```

Unfortunately, I didn't find a way to type `import_optional_dependency` (even with overloads, a module by itself is no type).

> Any changes needed for the pre-commit check?

No, pre-commit just calls `pyright` same as for the CI.
 I have a PR whch i'm just running the tests etc for before opening in which I use

```python
    if TYPE_CHECKING:
        import numba
    else:
        numba = import_optional_dependency("numba")
``` Thanks @twoertwein 