Skip to content

Instantly share code, notes, and snippets.

@gbiz123
gbiz123 / typehint_sqlalchemy_join.md
Last active January 8, 2024 23:17
How to Properly Type Hint SQLAlchemy Join Queries

How to Type Hint SQLAlchemy Join Queries

This Gist will show you how and why to properly type hint your SQLAlchemy join queries. Typehinting join queries is not well documented or discussed as of yet, but I'm here to change that.

If you are converting your ORM models to dictionaries, you are missing out!

If you aren't typehinting in SQLAlchemy, you're missing out on all the powerful ORM features that will speed your development and help prevent bugs. Properly typehinted Python code will give you specific benefits including:

  • Autocompletion of fields
  • Static analysis and linting
  • Clean code