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

fix(python-types): Enforce static typing in api/app namespace #5216

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mondaini
Copy link

@mondaini mondaini commented Mar 11, 2025

Thanks for submitting a PR! Please check the boxes below:

  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

  1. Added missing type hints to core modules in api/app/:

    • pagination.py
    • routers.py
    • views.py
    • utils.py
  2. Removed unused file:

    • Deleted api/app/handler.py as it's not being used in the codebase
  3. Key improvements:

    • Properly typed function parameters and return values
    • Added TypedDict for version information (VersionInfoDict)
    • Removed redundant type ignores from test files
    • Enhanced type safety for database routing and pagination logic

These changes will help catch type-related issues earlier in development and improve code maintainability.

How did you test this code?

Testing focused on ensuring type compliance:

  1. Ran mypy with strict settings on the api/app namespace
  2. Verified all existing tests pass without the previously required type ignores

- handlers.py
- pagination.py
- utils.py
- views.py
Added explicit None returns for readability.
Copy link

vercel bot commented Mar 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Mar 13, 2025 10:13am
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Mar 13, 2025 10:13am
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Mar 13, 2025 10:13am

Copy link

vercel bot commented Mar 11, 2025

@mondaini is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the api Issue related to the REST API label Mar 11, 2025
@mondaini mondaini closed this Mar 11, 2025
@mondaini mondaini reopened this Mar 11, 2025
@mondaini mondaini marked this pull request as ready for review March 11, 2025 19:25
@mondaini mondaini requested a review from a team as a code owner March 11, 2025 19:25
@mondaini mondaini requested review from matthewelwell and removed request for a team March 11, 2025 19:25
@mondaini
Copy link
Author

Tested the following instructions:

  • make test
  • make typecheck

@khvn26 khvn26 changed the title chore(types): enforce static typing in api/app namespace fix(python-types): Enforce static typing in api/app namespace Mar 11, 2025
Copy link
Contributor

github-actions bot commented Mar 11, 2025

Uffizzi Ephemeral Environment deployment-61792

☁️ https://app.uffizzi.com/github.com/Flagsmith/flagsmith/pull/5216

📄 View Application Logs etc.

What is Uffizzi? Learn more!

Copy link

codecov bot commented Mar 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.55%. Comparing base (d57f903) to head (db47af9).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5216      +/-   ##
==========================================
+ Coverage   97.51%   97.55%   +0.03%     
==========================================
  Files        1227     1226       -1     
  Lines       42619    42604      -15     
==========================================
+ Hits        41559    41561       +2     
+ Misses       1060     1043      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @mondaini and thanks a lot for your contribution.

It seems like your changes to api/app/handlers.py don't pass the obligatory 100% patch coverage check. Good news is, as confirmed with the team, this code is not used and the file can be safely removed 👍

@mondaini
Copy link
Author

mondaini commented Mar 11, 2025

Hello @mondaini and thanks a lot for your contribution.

It seems like your changes to api/app/handlers.py don't pass the obligatory 100% patch coverage check. Good news is, as confirmed with the team, this code is not used and the file can be safely removed 👍

Alright! I'll remove it and get back to you!

@mondaini mondaini requested a review from khvn26 March 11, 2025 22:38
@mondaini
Copy link
Author

Hello @mondaini and thanks a lot for your contribution.
It seems like your changes to api/app/handlers.py don't pass the obligatory 100% patch coverage check. Good news is, as confirmed with the team, this code is not used and the file can be safely removed 👍

Alright! I'll remove it and get back to you!

Done, @khvn26

@matthewelwell matthewelwell removed the request for review from khvn26 March 13, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants