dazzling-elephant-33766
02/07/2023, 11:40 AMmypy
working in pants check ::
with SQLAlchemy
?
I have the following in my mypy.ini
[mypy]
plugins = sqlalchemy.ext.mypy.plugin
I’ve added the following to my pants.toml
(I’ve tried with/without the stubs package)
[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:
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
➜ 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
[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"