question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Latest version seems to break mypy

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
cdpathcommented, 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'
1reaction
arusahnicommented, Mar 14, 2019

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tests aren't enough: Case study after adding type hints to urllib3
We wanted to add Mypy to our continuous integration to ensure new contributors wouldn't accidentally break type hints but we also wanted to ......
Read more >
Ubuntu Manpage: mypy - Optional static typing for Python
If an expression of type Any appears anywhere in the module mypy will output an error unless the expression is immediately used as...
Read more >
More types - mypy 0.991 documentation
More types#. This section introduces a few additional kinds of types, including NoReturn , NewType , TypedDict , and types for async code....
Read more >
Modernize Your Sinful Python Code with Beautiful Type Hints
It seems like mypy is okay with everything written so far. I now want to intentionally break the type hint to see what...
Read more >
mypy and basic inheritance [duplicate] - python - Stack Overflow
Obviously, this will break once any subclass of Parent introduces a field ... Ignoring the inheritance for a moment, this seems entirely ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found