dropbox / dropbox/sqlalchemy-stubs

Using uuid.UUID with PotgreSQL's UUID

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

Description

I have a model using PostgreSQL's UUID:

```python
from sqlalchemy.dialects import postgresql

class MyModel(Base):
__tablename__ = 'my-model'

some_id = Column(postgresql.UUID(as_uuid=True), nullable=False)
```

SQLAlchemy lets me create instances as follows:

```python
import uuid

a_uuid = uuid.uuid4()

MyModel(some_id=a_uuid)
MyModel(some_id=str(a_uuid))
```

However, the stubs here seem to only accept the latter, not the former:

```
error: Incompatible type for "some_id" of "MyModel" (got "UUID", expected "str")
```

Could support for the former be added?

(I tested with sqlalchemy-stubs master)

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.