Skip to content

Latest version seems to break mypy #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mehdigmira opened this issue Feb 3, 2019 · 7 comments
Closed

Latest version seems to break mypy #63

mehdigmira opened this issue Feb 3, 2019 · 7 comments

Comments

@mehdigmira
Copy link
Contributor

when running mypy on my project, I get this error:
Error importing plugin sqlmypy

When debugging a little bit, the problem seems to be here:

    def get_dynamic_class_hook(self, fullname: str) -> CB[DynamicClassDefContext]:
  File "/usr/lib/python3.5/typing.py", line 546, in __getitem__
    "Cannot subscript an existing Union. Use Union[u, t] instead.")
TypeError: Cannot subscript an existing Union. Use Union[u, t] instead.
@ilevkivskyi
Copy link
Contributor

You need to update Python to a newer version (I think at least 3.5.2, but better just the latest 3.5 version).

@arusahni
Copy link

I have this same error on Python 3.7.2:

$ python --version
Python 3.7.2

$ mypy --version
mypy 0.670

$ pip show sqlalchemy-stubs
Name: sqlalchemy-stubs
Version: 0.1
Summary: SQLAlchemy stubs and mypy plugin
Home-page: https://github.com/dropbox/sqlalchemy-stubs
Author: Ivan Levkivskyi
Author-email: [email protected]
License: MIT License
Location: /Users/aru/.virtualenvs/portal/lib/python3.7/site-packages
Requires: typing-extensions, mypy
Required-by:

In my setup.cfg:

[mypy]
plugins = sqlmypy

@ilevkivskyi
Copy link
Contributor

You can't have the same error on Python 3.7.2 because that line of code simply doesn't exist in Python 3.7.2, can you post exactly the traceback you see?

@arusahni
Copy link

I'm sorry, I don't know how I missed the traceback portion of the OP's error. I seem to be unable to generate a traceback?

$ mypy --tb package_name
setup.cfg:8: error: Error importing plugin 'sqlmypy'

@ilevkivskyi
Copy link
Contributor

Do you have sqlalchemy-stubs and mypy installed in the same virtualenv?

@arusahni
Copy link

I do... however, I discovered that, for whatever reason, my shell was using my global mypy. Forcing a re-hash fixed things. Sorry for the confusion!

@cdpath
Copy link

cdpath commented Jul 8, 2021

I fixed this issue by adding sqlalchemy-stubs explicitly in .pre-commit-config.yaml, like this:

-   repo: https://github.com/pre-commit/mirrors-mypy
    rev: 'v0.910'
    hooks:
    - id: mypy
      additional_dependencies:
        - 'pydantic'
        - 'sqlalchemy-stubs'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants