Has anyone had experience getting `mypy` working i...
# general
d
Has anyone had experience getting
mypy
working in
pants check ::
with
SQLAlchemy
? I have the following in my
mypy.ini
Copy code
[mypy]
plugins = sqlalchemy.ext.mypy.plugin
I’ve added the following to my
pants.toml
(I’ve tried with/without the stubs package)
Copy code
[mypy]
extra_requirements.add = ['SQLAlchemy<2.0.0,>=1.4.27', 'sqlalchemy-stubs']
lockfile = "3rdparty/mypy_lockfile.txt"
(this seems to be required because without which I get an error
error: Error importing plugin "sqlalchemy.ext.mypy.plugin": No module named 'sqlalchemy'
) I’ve also tried:
Copy code
extra_type_stubs = ['SQLAlchemy<2.0.0,>=1.4.27', 'sqlalchemy-stubs']
extra_type_stubs_lockfile = "3rdparty/extra_type_stubs.txt"
But running this still gives me the following error
Copy code
➜  example git:(pants-migration) ✗ ./pants check services/.../authorise.py
services/.../authorise.py: error: Skipping analyzing "sqlalchemy.orm.attributes": module is installed, but missing library stubs or py.typed marker
EDIT: okay so I’ve fixed it, it looks like the combination of settings I needed appear to be both
extra_requirements
and
extra_type_stubs
Copy code
[mypy]
extra_requirements.add = ['SQLAlchemy<2.0.0,>=1.4.27']
lockfile = "3rdparty/mypy_lockfile.txt"
extra_type_stubs = ['sqlalchemy2-stubs']
extra_type_stubs_lockfile = "3rdparty/extra_type_stubs.txt"
👍 1