dropbox / dropbox/sqlalchemy-stubs

Can't use Column with automatic data type and ForeignKey

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

Description

SQLAlchemy supports automatic type detection with foreign key columns:

```python
class MyModel(Model):
my_column = Column(None, ForeignKey('other_table.other_column'))
```

However this call variant is not present in the stubs. Mypy says:

```
error: No overload variant of "Column" matches argument types "None", "ForeignKey" [call-overload]
note: Possible overload variants:
note: def [_T] __init__(self, name: str, type_: Type[TypeEngine[_T]], *args: Any, autoincrement: Union[bool, str] = ..., default: Any = ..., doc: str = ..., key: str = ..., index: bool = ..., info: Mapping[str, Any] = ..., nullable: bool = ..., onupdate: Any = ..., primary_key: bool = ..., server_default: Any = ..., server_onupdate: Union[FetchedValue, FunctionElement[Any]] = ..., quote: Optional[bool] = ..., unique: bool = ..., system: bool = ..., comment: str = ...) -> Column[_T]
note: def [_T] __init__(self, name: str, type_: TypeEngine[_T], *args: Any, autoincrement: Union[bool, str] = ..., default: Any = ..., doc: str = ..., key: str = ..., index: bool = ..., info: Mapping[str, Any] = ..., nullable: bool = ..., onupdate: Any = ..., primary_key: bool = ..., server_default: Any = ..., server_onupdate: Union[FetchedValue, FunctionElement[Any]] = ..., quote: Optional[bool] = ..., unique: bool = ..., system: bool = ..., comment: str = ...) -> Column[_T]
note: <4 more similar overloads not shown, out of 6 total overloads>
```

This issue is distinct from #67 (Can't use ForeignKey in Column).

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.