Skip to content

Upgrade to Python 3.12 and latest dependencies#39

Open
omerXfaruq wants to merge 5 commits intomasterfrom
upgrade-python-3.12-and-dependencies
Open

Upgrade to Python 3.12 and latest dependencies#39
omerXfaruq wants to merge 5 commits intomasterfrom
upgrade-python-3.12-and-dependencies

Conversation

@omerXfaruq
Copy link
Copy Markdown
Owner

Major upgrades:

  • Python: 3.10 → 3.12
  • FastAPI: 0.70.1 → 0.121.3
  • Pydantic: 1.8.2 → 2.12.4 (v1 → v2 migration)
  • SQLAlchemy: 1.4.28 → 2.0.44
  • SQLModel: 0.0.4 → 0.0.27
  • Uvicorn: 0.16.0 → 0.38.0
  • All other dependencies upgraded to latest versions

Code changes:

  • Migrated from deprecated asyncio.get_event_loop() to asyncio.run()
  • Replaced @app.on_event('startup') with lifespan context manager
  • Updated Pydantic v1 API to v2:
    • .dict() → .model_dump()
    • .from_orm() → .model_validate()
  • Fixed Pydantic v2 validation issues:
    • Added default None to all Optional fields
    • Added ConfigDict(extra='ignore') to handle Telegram's extra fields
    • Fixed type mismatches (message_id: str→int, is_bot: str→bool)
  • Removed built-in modules from requirements (asyncio, typing, datetime)
  • Added missing dependencies (yfinance, pytest-asyncio)
  • Optimized pyngrok import to be conditional

Testing:

  • Refactored test suite into organized classes (55 unit tests)
  • Added comprehensive E2E test suite (16 tests)
  • Fixed pre-existing test bugs
  • All 71 tests passing

Documentation:

  • Updated repro.md with Python 3.12 and venv instructions
  • Added .gitignore for venv and common files
  • Added run_locally.sh script (uses environment variables for tokens)

Infrastructure:

  • Created Python 3.12 virtual environment
  • Updated requirements.in and requirements.txt
  • All code compatible with Python 3.12 and latest packages

you@example.com added 5 commits November 22, 2025 21:19
Major upgrades:
- Python: 3.10 → 3.12
- FastAPI: 0.70.1 → 0.121.3
- Pydantic: 1.8.2 → 2.12.4 (v1 → v2 migration)
- SQLAlchemy: 1.4.28 → 2.0.44
- SQLModel: 0.0.4 → 0.0.27
- Uvicorn: 0.16.0 → 0.38.0
- All other dependencies upgraded to latest versions

Code changes:
- Migrated from deprecated asyncio.get_event_loop() to asyncio.run()
- Replaced @app.on_event('startup') with lifespan context manager
- Updated Pydantic v1 API to v2:
  * .dict() → .model_dump()
  * .from_orm() → .model_validate()
- Fixed Pydantic v2 validation issues:
  * Added default None to all Optional fields
  * Added ConfigDict(extra='ignore') to handle Telegram's extra fields
  * Fixed type mismatches (message_id: str→int, is_bot: str→bool)
- Removed built-in modules from requirements (asyncio, typing, datetime)
- Added missing dependencies (yfinance, pytest-asyncio)
- Optimized pyngrok import to be conditional

Testing:
- Refactored test suite into organized classes (55 unit tests)
- Added comprehensive E2E test suite (16 tests)
- Fixed pre-existing test bugs
- All 71 tests passing

Documentation:
- Updated repro.md with Python 3.12 and venv instructions
- Added .gitignore for venv and common files
- Added run_locally.sh script (uses environment variables for tokens)

Infrastructure:
- Created Python 3.12 virtual environment
- Updated requirements.in and requirements.txt
- All code compatible with Python 3.12 and latest packages
- Added python-dotenv to load environment variables from .env file
- Updated src/__init__.py to automatically load .env file on startup
- Created .env.example as a template for users
- Updated run_locally.sh with instructions about .env file
- Environment variables can now be set via .env file or exported directly
- .env file is already in .gitignore to prevent committing secrets
- Merged setup instructions from repro.md into README.md
- Added .env configuration instructions
- Added testing section
- Removed redundant repro.md file
- Standard practice: all setup info in README.md
- Fixed .env file loading order: load_dotenv() must be called before importing Events
  (Events.TOKEN is evaluated at class definition time)
- Removed all venv mentions from repro.md
- Added Configuration section documenting .env file usage
- Fixed NGROK_AUTH_TOKEN to NGROK_TOKEN in documentation
- .env file now properly loads before Events class is evaluated
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.

1 participant