dropbox / dropbox/sqlalchemy-stubs

Bug when field is named `id`

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

Description

I maintain a "realworld example app" for Pyramid, a popular Python Web framework. The example app uses SQLAlchemy. Recently I added `sqlalchemy-stubs` to the project to showcase how to do typing for SQLAlchemy models. And I've hit a bug:

When I define an `id` field in my model [like so](https://github.com/niteoweb/pyramid-realworld-example-app/blob/ac744b299464ea51627aa6d921aa9ed1794eb6db/src/conduit/comment/models.py#L48):

```python
id = Column(Integer)
```

then I get the following error:

```
src/conduit/comment/models.py:48: error: Argument 1 to "Column" has incompatible type "Type[Integer]"; expected "Type[TypeEngine[str]]"
```

However, If I change the line to:

```
id_ = Column(Integer)
```

or

```
foo = Column(Integer)
```

then mypy says everything is good. Is this a bug or am I doing something wrong?

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.