Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy for sqlalchemy #402

Merged
merged 2 commits into from
May 9, 2024
Merged

mypy for sqlalchemy #402

merged 2 commits into from
May 9, 2024

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.

@@ -211,7 +211,7 @@ def update_chat(session: Session, user: str, chat: schemas.Chat) -> None:
orm_chat = _get_orm_chat(session, user=user, id=chat.id)

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
12 checks passed
@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