Skip to content

Fix template doctests, ruff target version, and AGENTS.md drift - #100

Merged
glenn-jocher merged 1 commit into
mainfrom
standardize-agents-md
Aug 2, 2026
Merged

Fix template doctests, ruff target version, and AGENTS.md drift#100
glenn-jocher merged 1 commit into
mainfrom
standardize-agents-md

Conversation

@glenn-jocher

@glenn-jocher glenn-jocher commented Aug 2, 2026

Copy link
Copy Markdown
Member

Fixes found while standardizing this repo. Since every new Ultralytics Python project is copied from here, each of these propagates.

  • pytest failed out of the box. addopts includes --doctest-modules, so a bare pytest at the repo root collects template/module1.py and fails twice: add_numbers documented torch.Tensor arguments the signature does not accept and its example called torch.tensor(...) (torch is not a dependency → NameError), and the main() example expected no output while main prints. CI only ever runs pytest tests, which is why this stayed hidden. Docstrings now match the real signature and output; bare pytest goes from 2 failed / 5 passed to 7 passed.
  • target-version = "py310" contradicted requires-python = ">=3.9". With select = ["UP"] this makes ruff rewrite Optional[int] to int | None, which is a runtime error on the 3.9 that CI still tests. Removed the line so ruff infers the target from requires-python, keeping the Python floor in one place — verified that the same file is clean before the change and flagged after.
  • package-data = { "sample" = ["*.yaml"] } referenced a sample package that does not exist; setuptools silently ignored it. Removed.
  • The install hint in the header comment recommended a TOKEN:x-oauth-basic URL for what is a public repository. Simplified.
  • format.yml: use secrets.GITHUB_TOKEN in the fallback to match every other Ultralytics repo.
  • AGENTS.md: replace the drifted Core Principles and PR Workflow sections with the current org-standard text; repo-specific sections unchanged.

Verified locally on 3.13: bare pytest, pytest tests, unittest discover tests, both coverage variants, example-cli-command, ruff format --check, and ruff check all pass.

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Simplifies the template repository’s documentation, configuration, workflow authentication, and example code for a cleaner and more maintainable developer experience. ✨

📊 Key Changes

  • 🔐 Updated the formatting workflow to use secrets.GITHUB_TOKEN as the fallback authentication token.
  • 🧭 Reworked AGENTS.md with clearer contribution principles, emphasizing minimal changes, reuse, deletion of unnecessary code, and thorough validation.
  • 🌿 Strengthened Git workflow guidance, including use of feature branches and worktrees and avoiding direct changes to main.
  • 📦 Simplified the installation example in pyproject.toml by removing the token-based Git URL.
  • 🧹 Removed obsolete setuptools package-data configuration and the hardcoded Ruff Python target version.
  • 📝 Simplified add_numbers() documentation to reflect its supported integer and floating-point inputs.
  • ✅ Updated doctest examples for add_numbers() and main() to show expected output directly.

🎯 Purpose & Impact

  • 🚀 Makes the template easier and safer to use for new projects and contributors.
  • 🔒 Reduces reliance on explicit authentication tokens in installation and CI workflows.
  • 🛠️ Provides clearer AI-agent and contributor guidance, helping prevent unnecessary abstractions and workflow mistakes.
  • 🧼 Removes outdated or unused configuration, reducing maintenance overhead.
  • 📚 Improves documentation accuracy by aligning examples and type descriptions with the actual implementation.

@UltralyticsAssistant UltralyticsAssistant added bug Something isn't working devops GitHub Devops or MLops documentation Improvements or additions to documentation labels Aug 2, 2026
@UltralyticsAssistant

Copy link
Copy Markdown
Member

👋 Hello @glenn-jocher, thank you for submitting a ultralytics/template 🚀 PR! To ensure a seamless integration of your work, please review the following checklist:

  • 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

For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. This is an automated message, and an engineer will assist with any follow-up questions. Thank you for contributing to Ultralytics! 🚀

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@UltralyticsAssistant UltralyticsAssistant left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🔍 PR Review

Made with ❤️ by Ultralytics Actions

LGTM. The doctest examples now match runtime behavior, Ruff can infer the Python 3.9 target from project.requires-python, the obsolete setuptools package-data entry has no corresponding package, and the GitHub Actions token expression remains valid.

@glenn-jocher
glenn-jocher merged commit 2ccfc94 into main Aug 2, 2026
15 checks passed
@glenn-jocher
glenn-jocher deleted the standardize-agents-md branch August 2, 2026 18:10
@UltralyticsAssistant

Copy link
Copy Markdown
Member

🎉 Thank you, @glenn-jocher, for this excellent contribution—and congratulations on the merge!

“Simplify, simplify.” — Henry David Thoreau

This PR puts that principle into practice by streamlining documentation, configuration, authentication, workflows, and examples. The result is a cleaner, safer, and more maintainable template that gives contributors clearer guidance and a smoother developer experience. Thank you for helping make the foundation stronger for everyone!

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

Labels

bug Something isn't working devops GitHub Devops or MLops documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants