Skip to content

mypy for sqlalchemy#402

Merged
pmeier merged 2 commits intomainfrom
mypy-sqlalchemy
May 9, 2024
Merged

mypy for sqlalchemy#402
pmeier merged 2 commits intomainfrom
mypy-sqlalchemy

Conversation

@pmeier
Copy link
Member

@pmeier pmeier commented May 3, 2024

While looking into the lint issues of #401, I realized we never activated the SQLAlchemy mypy plugin. This PR makes up for that.

This surfaces some errors. When columns are defined without nullable=False, the value of the field is always Optional[T]. Since we don't have None values and won't have them for the currently available columns in the future, I've set nullable=False everywhere.


orm_chat.prepared = chat.prepared
orm_chat.messages = [
orm_chat.messages = [ # type: ignore[assignment]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mypy incorrectly infers orm.Chat.messages to be of type orm.Message rather than the correct list[orm.Message]. Thus, we just silence it here.

@pmeier pmeier merged commit 3cef0f7 into main May 9, 2024
@pmeier pmeier deleted the mypy-sqlalchemy branch May 9, 2024 06:49
pmeier added a commit that referenced this pull request Jun 28, 2024
pmeier added a commit that referenced this pull request Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant