Skip to content

Upgrade Python from 3.8 to 3.13 and update dependencies#2

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1756166816-python313-upgrade
Open

Upgrade Python from 3.8 to 3.13 and update dependencies#2
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1756166816-python313-upgrade

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Upgrade Python from 3.8 to 3.13 and update dependencies

Summary

This PR upgrades the FastAPI application from Python 3.8 to Python 3.13, including major dependency updates and compatibility fixes. Key changes include:

  • Python version: 3.8 → 3.13
  • FastAPI: 0.54.1 → 0.116.0 (major version upgrade)
  • SQLAlchemy: 1.3.16 → 2.0.0 (major version upgrade with breaking changes)
  • Docker base image: Changed from tiangolo/uvicorn-gunicorn-fastapi:python3.8 to python:3.13-slim
  • Pydantic v2 migration: Added pydantic-settings and updated configuration patterns
  • Poetry installation: Updated to modern installation method
  • All dev dependencies: Updated to Python 3.13 compatible versions

The upgrade required addressing several breaking changes:

  • Pydantic v2: Moved BaseSettings to pydantic-settings, updated validators and config syntax
  • SQLAlchemy 2.0: Added string conversion for database URI compatibility
  • Docker: Added explicit uvicorn startup command since the specialized image was replaced

Review & Testing Checklist for Human

⚠️ High-risk upgrade requiring thorough testing - 4 critical items to verify:

  • End-to-end API testing: Start the application locally and test all API endpoints (GET/POST requests, database operations) to ensure no regressions from the major FastAPI/SQLAlchemy upgrades
  • Docker deployment verification: Build and run the application using docker-compose up to verify the new python:3.13-slim base image works correctly and performance is acceptable
  • Database connectivity: Test database connections, migrations, and CRUD operations work with SQLAlchemy 2.0 and the updated configuration system
  • Environment configuration: Verify environment variable loading from .env file works correctly with the new Pydantic v2 settings system

Test Plan Recommendation

  1. Run poetry install && poetry run pytest to verify tests pass
  2. Start application with poetry run uvicorn app.main:app --reload
  3. Test API endpoints manually or with automated tests
  4. Build and test Docker deployment: docker-compose build && docker-compose up
  5. Verify database operations work in both local and Docker environments

Notes

  • Basic functionality verified: imports work, single test passes, app starts successfully
  • Full end-to-end testing still needed given the scope of dependency changes
  • The specialized FastAPI Docker image was replaced with generic Python image + manual uvicorn configuration

Link to Devin run: https://app.devin.ai/sessions/dca6232eece74a3f9e4c017d1ac745b7
Requested by: Sam Fertig (@samfert-codeium)

- Update Python version to ^3.13 in pyproject.toml
- Update Dockerfile to use python:3.13-slim base image
- Upgrade FastAPI to ^0.116.0 and SQLAlchemy to ^2.0.0
- Add pydantic-settings ^2.0.0 for Pydantic v2 compatibility
- Update all dev dependencies to Python 3.13 compatible versions
- Fix Pydantic v2 breaking changes in config.py:
  - Replace BaseSettings import with pydantic_settings
  - Update validator to field_validator with new syntax
  - Replace Config class with model_config dictionary
  - Fix PostgresDsn.build to use username instead of user
- Convert PostgresDsn to string for SQLAlchemy 2.0 compatibility
- Update Poetry installation method in Dockerfile
- Add uvicorn startup command to Dockerfile

All tests pass with Python 3.13.1

Co-Authored-By: Sam Fertig <sam.fertig@codeium.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants