TYP: enable reportUnusedImport
pyright's reportUnusedImport checks py and pyi files for unused imports. If an import is explicitly marked as public (re-exported using `as` or in `__all__`) it is "used" (flake8 seems to use the same definition).

Adding unused imports to `__all__` becomes messy when the file does not yet have `__all__`: need to list also all public symbols (constants, classes, functions).
This pull request is stale because it has been open for thirty days with no activity. Please [update](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this. This generally looked okay if you want to merge main. `__all__` as two functions: 1) it affects `from xyz import *` (imports only functions/classes inside `__all__`) and 2) in a py.typed library `__all__` defines the public interface of a module (unless the module is private, starts with `_`).

>     1. Nothing changed from the "public" API?

Technically, users will import fewer modules if they use `from xyz import *` which could be a public API change.

>     2. In terms of code flow, we will need to ensure all "unused" imports are defined in `__all__`?

flake8/pyright will let you know about unused imports :) They can then either be removed, be ignored (if they have some side effects), or added to `__all__` if they are meant to be public. > Technically, users will import fewer modules if they use from xyz import * which could be a public API change.

Could you do a quick before/after check when `from pandas import *` is run? I imagine it should hopefully not change in a negative way, and maybe can be noted as a benefit that less stuff is imported :) Seems there is actually no differences between main and this PR when imported everything from a file:

```py
import importlib
from pathlib import Path
import pickle

import ipdb

imported = {}
for py in Path("pandas").glob("**/*.py"):
    print(py)
    py = str(py).replace("/", ".").removesuffix(".py")
    mod = importlib.import_module("py")
    imported[py] = [x for x in dir(mod) if not x.startswith("_")]
with open("before.pickle", mode="wb") as file:
    pickle.dump(imported, file)

# ran the above first on this PR and save as after.pickle
# and then the entire script on main

after = {}
with open("after.pickle", mode="rb") as file:
    after = pickle.load(file)

for py, imports_b in imported.items():
    imports_a = set(after[py])
    imports_b = set(imports_b)
    remove = imports_b.difference(imports_a)
    added = imports_a.difference(imports_b)

    if len(remove) > 0 or len(added) > 0:
        ipdb.set_trace()  # never ended up here
``` Thanks for double checking @twoertwein! 