## Summary
Removes 4 dead symbols from SQLAlchemy's typing modules. Each symbol has **zero references** across `lib/`, `test/`, `doc/`, `tools/`, and `examples/` — verified by grep for direct references, string forward references, and `getattr`-style dynamic access.
## Changes
**`lib/sqlalchemy/util/typing.py`**
- Remove `from . import compat` — unused module import; the only occurrence of `compat` in the file is in a code comment on line 221
- Remove `_KT_co = TypeVar("_KT_co", covariant=True)` — unused TypeVar
- Remove `_KT_contra = TypeVar("_KT_contra", contravariant=True)` — unused TypeVar
**`lib/sqlalchemy/orm/_typing.py`**
- Remove `_T_co = TypeVar("_T_co", bound=Any, covariant=True)` — orphaned; `orm.base` imports `_T_co` from `sql._typing` instead, and other orm modules (`interfaces.py`, `attributes.py`) define their own local `_T_co`
Total: **-7 lines**, no additions.
## Verification
For each removed symbol:
| Symbol | Repo-wide grep result |
|---|---|
| `compat` (in `util/typing.py`) | 0 references to `compat.` or `util.typing.compat` outside the import itself |
| `_KT_co` | 1 hit total (the removed definition line) |
| `_KT_contra` | 1 hit total (the removed definition line) |
| `_T_co` (in `orm/_typing.py`) | No `from sqlalchemy.orm._typing import _T_co` or `from ..orm._typing import _T_co` anywhere; all consumers import from `sql._typing` or define locally |
Additionally checked:
- No `__all__` references
- No string forward references (e.g. `"_KT_co"`)
- No `getattr(..., "_T_co")` or similar dynamic access
- No re-exports via `util/__init__.py` or any other module
- `test/base/test_typing_utils.py` (which imports `util.typing as sa_typing`) does not touch any of these names
## Test plan
- [x] `pre-commit` hooks pass (black, zimports, flake8)
- [x] `import sqlalchemy`, `sqlalchemy.orm`, `sqlalchemy.util.typing`, `sqlalchemy.orm._typing`, `sqlalchemy.sql._typing`, `sqlalchemy.dialects._typing` — all import cleanly
- [x] Broad import smoke test: `Mapped`, `DeclarativeBase`, `relationship`, `Session`, `Mapper`, `mapped_column`, `Column`, `select`, `create_engine`, `MetaData`, `QueuePool`, `hybrid_property`, `association_proxy` — all import cleanly
- [x] Full `tox` / test suite — would appreciate CI confirmation
## Not included (intentionally)
- `LiteralString` re-export in `util/typing.py:54` — has 0 in-tree consumers but is an explicit `as X as X` public re-export; kept for API stability
- `is_origin_of` rename to `_is_origin_of` — used only internally by `is_union`, but renaming is a minor breaking change not worth the churn
Closes: #13244
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13244
Pull-request-sha:
8242f373685c35264ffd52071345a6dfce855277
Change-Id: Iae389447ac46599df27ab9776ff5ad19dfef4e2c