Update ruff to be more strict#2279
Open
nielsond wants to merge 13 commits intofastapi:masterfrom
Open
Conversation
added 7 commits
May 8, 2026 23:11
… development commands
There was a problem hiding this comment.
Pull request overview
This PR updates local email testing from Mailcatcher to Mailpit across Docker Compose, docs, and Playwright tests, and tightens backend linting by making Ruff more strict while modernizing some Python code patterns.
Changes:
- Replace Mailcatcher with Mailpit (compose override, docs, Playwright email test utilities).
- Update Ruff configuration and apply related cleanup/modernizations (imports, exception chaining, datetime handling).
- Fix generated TanStack router route tree typings for the index route.
Reviewed changes
Copilot reviewed 20 out of 21 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
tasklist.yaml |
Adds a task runner config for dev/stop/lint/test commands. |
README.md |
Updates local email testing reference from Mailcatcher to Mailpit. |
frontend/tests/utils/mailpit.ts |
Switches Playwright email polling utility to Mailpit API and new response shape. |
frontend/tests/reset-password.spec.ts |
Updates reset-password E2E flow to read email HTML via Mailpit API. |
frontend/src/routeTree.gen.ts |
Corrects generated route mappings for '/' and layout fullPath. |
development.md |
Updates local development docs to reference Mailpit and port 8025. |
compose.override.yml |
Replaces Mailcatcher service with Mailpit and updates env vars/ports. |
backend/scripts/send_test_email.py |
Adds a helper script to send a test email using SMTP env settings. |
backend/pyproject.toml |
Tightens Ruff config (target-version/rules) and formatting settings. |
backend/app/utils.py |
Updates UTC datetime creation used for password reset tokens. |
backend/app/models.py |
Updates UTC datetime helper used in models. |
backend/app/core/security.py |
Updates JWT expiry datetime creation. |
backend/app/core/config.py |
Replaces typing_extensions.Self usage with typing.Self. |
backend/app/api/deps.py |
Chains credential validation exceptions (raise ... from err). |
backend/app/alembic/versions/fe56fa70289e_add_created_at_to_user_and_item.py |
Cleans migration imports. |
backend/app/alembic/versions/d98dd8ec85a3_edit_replace_id_integers_in_all_models_.py |
Cleans migration imports. |
backend/app/alembic/versions/9c0a54914c78_add_max_length_for_string_varchar_.py |
Cleans migration imports. |
backend/app/alembic/versions/1a31ce608336_add_cascade_delete_relationships.py |
Cleans migration imports. |
backend/app/alembic/env.py |
Removes an unused import. |
.gitignore |
Ignores generated TS files and .env. |
.example.env |
Updates example SMTP defaults to Mailpit-friendly local settings. |
Comments suppressed due to low confidence (1)
frontend/tests/utils/mailpit.ts:32
- The Mailpit API request response isn’t checked before calling
response.json(). If Mailpit is unavailable or returns a non-2xx response, this will throw a less actionable JSON parse error. Consider assertingresponse.ok()(or checkingstatus()) and throwing a clearer error that includes the status/body.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+4
to
+19
| dev: | ||
| desc: Start the full development stack | ||
| cmds: - docker compose up -d | ||
|
|
||
| stop: | ||
| desc: Stop all services | ||
| cmds: - docker compose down | ||
|
|
||
| lint: | ||
| desc: Run ultra-fast linting and formatting | ||
| cmds: - cd backend && uv run ruff check . --fix - cd backend && uv run ruff format . | ||
|
|
||
| gate: | ||
| desc: Run all quality gates (Lint + Tests) | ||
| deps: [lint] | ||
| cmds: - cd backend && uv run pytest |
Comment on lines
1
to
5
| import logging | ||
| from dataclasses import dataclass | ||
| from datetime import datetime, timedelta, timezone | ||
| from datetime import UTC, datetime, timedelta | ||
| from pathlib import Path | ||
| from typing import Any |
Comment on lines
1
to
3
| import uuid | ||
| from datetime import datetime, timezone | ||
| from datetime import UTC, datetime | ||
|
|
Comment on lines
1
to
3
| from datetime import UTC, datetime, timedelta | ||
| from typing import Any | ||
|
|
Comment on lines
1
to
5
| import secrets | ||
| import warnings | ||
| from typing import Annotated, Any, Literal | ||
| from typing import Annotated, Any, Literal, Self | ||
|
|
||
| from pydantic import ( |
Comment on lines
+8
to
11
|
|
||
| import sqlalchemy as sa | ||
| import sqlmodel.sql.sqltypes | ||
| from alembic import op | ||
| from sqlalchemy.dialects import postgresql |
Comment on lines
+9
to
+10
| import sqlalchemy as sa | ||
| from alembic import op |
Comment on lines
+9
to
+10
| import sqlalchemy as sa | ||
| from alembic import op |
| `${process.env.MAILCATCHER_HOST}/messages/${emailData.id}.html`, | ||
| const htmlResponse = await request.get( | ||
| `${process.env.MAILPIT_HOST}/api/v1/message/${emailData.ID}/part/html`, | ||
| ) |
Comment on lines
+110
to
+113
| const htmlResponse = await request.get( | ||
| `${process.env.MAILPIT_HOST}/api/v1/message/${emailData.ID}/part/html`, | ||
| ) | ||
| const html = await htmlResponse.text() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request migrates the development email testing setup from Mailcatcher to Mailpit, updates related documentation and configuration, and introduces several improvements and cleanups across the backend and frontend. The most notable changes are the replacement of Mailcatcher with Mailpit for local email testing, updates to environment and configuration files, and improvements to Python code for better standards compliance and clarity.
Email Testing Migration and Configuration:
Replaced Mailcatcher with Mailpit in Docker Compose (
compose.override.yml), including service name, image, ports, and environment variables. All references to Mailcatcher in documentation (README.md,development.md) and frontend tests have been updated to Mailpit and its new UI port (8025). [1] [2] [3] [4] [5] [6] [7] [8] [9]Updated example environment variables (
.example.env, renamed from.env) to use Mailpit defaults, such asSMTP_HOST=localhost,SMTP_PORT=1025,EMAILS_FROM_EMAIL=noreply@example.com, and clarified email sender name and TLS/SSL usage.Added a new utility script
backend/scripts/send_test_email.pyto send test emails using current environment or.envsettings, aiding developers in verifying email configuration.Backend Code Modernization and Cleanup:
Updated all usages of timezone-aware datetime creation to use the Python 3.11+
UTCconstant instead oftimezone.utc, improving clarity and future compatibility in files such asmodels.py,security.py, andutils.py. [1] [2] [3] [4] [5]Cleaned up Alembic migration scripts by removing unnecessary imports and standardizing import order for consistency and readability. [1] [2] [3] [4] [5]
Improved error handling in the
get_current_userdependency to chain exceptions usingfrom err, providing better traceback and debugging information.Tooling and Linting Updates:
pyproject.tomlto target Python 3.12, enabled additional linting rules, and adjusted formatting settings for improved code quality and consistency.Frontend Route Generation Fix:
frontend/src/routeTree.gen.ts) to correctly represent the index route ('/') and its type mapping, ensuring type safety and correct route resolution. [1] [2] [3]