Skip to content

INTERNAL ERROR triggered by broken typing #219

@aberres

Description

@aberres

Describe the bug
Exception with INTERNAL ERROR: maximum semantic analysis iteration count reached

Expected behavior

A message like error: Name "Address" is not defined [name-defined]

To Reproduce
Type check the code below.

Obviously, there is not class Address. When removing the base class, the error is emitted as expected. Stumbled upon this problem when having a typo in a relation.

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)
        addresses: list[Address]

Error

Deferral trace:
    [...]
    m2p.utils.tests.test_softdelete:12
    m2p.utils.tests.test_softdelete:12
    m2p.utils.tests.test_softdelete:12
    m2p.utils.tests.test_softdelete:12
    m2p.utils.tests.test_softdelete:12
    m2p.utils.tests.test_softdelete:12
    m2p.utils.tests.test_softdelete:12
test_softdelete.py: error: INTERNAL ERROR: maximum semantic analysis iteration count reached

Versions.

  • Python: 3.10
  • SQLAlchemy: 1.4.39
  • mypy: 0.961
  • SQLAlchemy2-stubs: 0.0.2a24

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmypy pluginsomething that has to do with the sqlalchemy mypy plugin

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions