dropbox / sqlalchemy-stubs

Mypy plugin and stubs for SQLAlchemy
Apache License 2.0
570 stars 101 forks source link

sqlalchemy-stubs are installed in conda environment and entered in mypy.ini, but in pre-commit, one gets error: Error importing plugin "sqlmypy": No module named 'sqlmypy' #243

Open serhiy-yevtushenko opened 2 years ago

serhiy-yevtushenko commented 2 years ago

I have installed sqlaclhemy-stubs in my local environment (I have tried both versions from pypi and the development version from the github), but when I tried to run mypy analysis via pre-commit, I'm getting the following error message from the mypy:

mypy.ini:6:1: error: Error importing plugin "sqlmypy": No module named 'sqlmypy'

python version is 3.8 mypy version is 0.961 sqlalchemy-stubs version is 0.4

sohnya commented 2 years ago

@serhiy-yevtushenko this is my pre-commit config that did the trick:

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: 'v0.961'
    hooks:
    -   id: mypy
        additional_dependencies:
          - sqlalchemy-stubs
serhiy-yevtushenko commented 2 years ago

Thanks a lot.

The suggested fix solves my issue.

It would be good to describe this use-case in the documentation, as I believe it is a pretty frequently occuring one.