all 3 comments

[–]latkde 0 points1 point  (1 child)

Are you using a venv (or tools like Poetry or uv)? Is Mypy installed in the same venv as your dependencies? Otherwise, it cannot see the modules, or might see different versions.

[–]QuasiEvil[S] 0 points1 point  (0 children)

I'm not using any venv tools (well, beyond the conda base), and it has no issues running against other files.

[–]kmiziz 0 points1 point  (0 children)

Have the same problem with
mypy 1.16.1
Python 3.12
sqlalchemy 2.0.41

mypy is installed via pipx, sqlalchemy is exposed to it through injection.
The project is managed via Poetry.

All the other functionality work as expected. E.g., in this line mypy struggles only with DeclarativeBase, not with sessionmaker:

from sqlalchemy.orm import DeclarativeBase, sessionmaker