dropbox / dropbox/sqlalchemy-stubs

`backref` relationships raise `has no attribute`

Open
#168 1 comment 5 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
583
Forks
96
PR merge metrics
No merged PRs in 30d

Description

For example, the following code fails to validate:
```python
from sqlalchemy.orm import backref, relationship
from sqlalchemy.sql.schema import Column, ForeignKey
from sqlalchemy.sql.sqltypes import Integer
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()
class A(Base):
id = Column(Integer, primary_key=True)

class B(Base):
id = Column(Integer, primary_key=True)
a_id = Column(
Integer, ForeignKey('a.id', ondelete='CASCADE'), index=True, nullable=False
)

a = relationship(A, backref=backref('bs'))

print(B().a)
print(A().bs)

```

```
sql.py:24: error: "A" has no attribute "bs"
Found 1 error in 1 file (checked 1 source file)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.