dropbox / dropbox/sqlalchemy-stubs

Hints do not work with imported Base

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

Description

There are no hints in PyCharm for models, which inherit declarative base from another module.
Here is example:

```python
# base.py
import re

from sqlalchemy import Column, Integer, DateTime
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.sql import func
from sqlalchemy.ext.declarative import declarative_base

class Base:
@declared_attr
def __tablename__(cls):
return cls.__name__.lower()

id = Column(Integer, primary_key=True, index=True)
created_at = Column(DateTime(timezone=True), nullable=False, server_default=func.now())

Base = declarative_base(cls=Base)
```

```python
# models.py
from base import Base
from sqlalchemy import Integer, String, Column

class SomeModel(Base):
id = Column(Integer, primary_key=True)
name = Column(String)
description = Column(String)
```

![изображение](https://user-images.githubusercontent.com/12518419/185610337-dcc46d4b-2209-459d-b57a-6e14e71ad774.png)

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.