Skip to content

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Sep 1, 2025

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Raises minimum Python version to 3.9 and adds type hints across the template and tests, improving type safety and developer experience. ⚙️✨

📊 Key Changes

  • Updated Python requirement in pyproject.toml from >=3.8 to >=3.9; removed the Python 3.8 classifier. 📦
  • Added precise type hints:
    • add_numbers(a: int | float, b: int | float) -> int | float
    • main() -> None
  • Annotated test functions with -> None for clarity and static analysis. ✅

🎯 Purpose & Impact

  • Cleaner APIs and better tooling support (type checkers, IDEs) for a smoother dev experience. 🧰
  • Dropping Python 3.8 reduces maintenance overhead and aligns with more modern Python features. ⬆️
  • Important note: the int | float union syntax requires Python 3.10+. With the current >=3.9 requirement, this may cause SyntaxErrors on Python 3.9.
    • Options to address:
      • Add from __future__ import annotations at the top of affected files, or
      • Replace with from typing import Union and Union[int, float], or
      • Bump minimum Python version to >=3.10. ⚠️

Example fix (if keeping Python 3.9):

from __future__ import annotations

def add_numbers(a: int | float, b: int | float) -> int | float:
    return a + b

Copy link

codecov bot commented Sep 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@UltralyticsAssistant UltralyticsAssistant added the enhancement New feature or request label Sep 1, 2025
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@UltralyticsAssistant
Copy link
Member

👋 Hello @glenn-jocher, thank you for submitting an ultralytics/template 🚀 PR! This is an automated response — an Ultralytics engineer will review and assist soon. In the meantime, please review the checklist below to ensure a smooth integration:

  • Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • Synchronize with Source: Confirm your PR is synchronized with the ultralytics/template main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • Update Documentation: Update the relevant documentation for any new or modified features.
  • Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

Notes specific to this PR:

  • Thanks for adding explicit type hints and keeping runtime behavior unchanged 🙌
  • If using union syntax with the pipe operator, ensure CI and supported environments target Python 3.10+ accordingly ⚠️
  • Confirm that tests and any tooling (linters/type checkers) align with the updated annotations 🧪

For more guidance, please refer to our Contributing Guide. Don’t hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀

@glenn-jocher glenn-jocher merged commit f6f1068 into main Sep 1, 2025
11 of 13 checks passed
@glenn-jocher glenn-jocher deleted the type-hints branch September 1, 2025 21:13
@UltralyticsAssistant
Copy link
Member

🎉 Huge thanks for the merge, @glenn-jocher! PR #64 is a big step forward—raising the bar to Python 3.9 and weaving in type hints will sharpen our developer experience and keep the template future-ready.

“The details are not the details. They make the design.” — Charles Eames

Your attention to type safety and clarity embodies this. Quick note on the int | float unions: we can follow up with from __future__ import annotations for 3.9 compatibility or consider bumping to 3.10. Either way, this lays a cleaner path for contributors and elevates quality across our templates and Ultralytics HUB projects.

Appreciate the craftsmanship and momentum you bring—thank you! 🚀

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants