- 
                Notifications
    
You must be signed in to change notification settings  - Fork 40
 
Open
Labels
bugSomething isn't workingSomething isn't workingmypy pluginsomething that has to do with the sqlalchemy mypy pluginsomething that has to do with the sqlalchemy mypy plugin
Description
Describe the bug
Given the code below I regularly run into a mypy crash when the cache is warm.
Expected behavior
No crash
To Reproduce
I am having a hard time to isolate the crash. It seems to be a combination of different (namespace?) packages and a change of the cache is needed.  I tried to come up with a minimal example but failed.
Maybe it does ring a bell nevertheless... As the class is created in a function there is no module which can be looked up.
We ran into the issue when introducing a new test which creates a base class within the test function. Whenever we switched branches mypy crashed. The workaound is to move the instantiation out into the model.
from __future__ import annotations
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
def test_soft():
    Base = declarative_base()
    class User(Base):
        __tablename__ = "user"
        id = Column(Integer, primary_key=True)
        name = Column(String)Error
Traceback (most recent call last):
  File "/Users/armin/venv/weplan3.10/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
  File "/Users/armin/venv/weplan3.10/lib/python3.10/site-packages/mypy/__main__.py", line 12, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "mypy/main.py", line 96, in main
  File "mypy/main.py", line 173, in run_build
  File "mypy/build.py", line 154, in build
  File "mypy/build.py", line 230, in _build
  File "mypy/build.py", line 2729, in dispatch
  File "mypy/build.py", line 3080, in process_graph
  File "mypy/build.py", line 3158, in process_fresh_modules
  File "mypy/build.py", line 1991, in fix_cross_refs
  File "mypy/fixup.py", line 26, in fixup_module
  File "mypy/fixup.py", line 91, in visit_symbol_table
  File "mypy/fixup.py", line 49, in visit_type_info
  File "mypy/types.py", line 1174, in accept
  File "mypy/fixup.py", line 156, in visit_instance
  File "mypy/fixup.py", line 282, in lookup_fully_qualified_typeinfo
  File "mypy/lookup.py", line 29, in lookup_fully_qualified
AssertionError: Cannot find module for Base
Versions.
- Python: 3.10
 - SQLAlchemy: 1.4.39
 - mypy: 0.961
 - SQLAlchemy2-stubs: 0.0.2a24
 
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmypy pluginsomething that has to do with the sqlalchemy mypy pluginsomething that has to do with the sqlalchemy mypy plugin