Skip to content

Conversation

edmorley
Copy link

@edmorley edmorley commented Sep 26, 2025

Since the runtime.txt file is deprecated:
https://devcenter.heroku.com/changelog-items/3141


This change is Reviewable

Summary by CodeRabbit

  • Chores
    • Standardized Python version management to ensure consistent local environments.
    • Removed redundant runtime version pin to avoid conflicts and simplify deployment.

Copy link

coderabbitai bot commented Sep 26, 2025

Walkthrough

Added a new .python-version file specifying Python 3.13. Removed the Python version line from runtime.txt.

Changes

Cohort / File(s) Summary of Changes
Python version management
\.python-version, runtime.txt
Added .python-version with "3.13". Removed the Python 3.13.3 specification from runtime.txt (deleted single line).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely states that the pull request replaces the deprecated runtime.txt with a .python-version file, matching the main changes in the diff.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 58b6ef6 and 5f6cdd2.

📒 Files selected for processing (2)
  • .python-version (1 hunks)
  • runtime.txt (0 hunks)
💤 Files with no reviewable changes (1)
  • runtime.txt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis

@@ -0,0 +1 @@
3.13
Copy link

@coderabbitai coderabbitai bot Sep 26, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Pin the Python version to the exact patch.

Heroku’s Python buildpack reads .python-version via pyenv and expects a fully qualified version (e.g., 3.13.3). Using only 3.13 removes the patch-level pin, so each deploy may silently jump to a newer patch or fail once that tag disappears. Please keep the patch version to preserve deterministic builds.

-3.13
+3.13.3
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
3.13
3.13.3
🤖 Prompt for AI Agents
.python-version lines 1-1: currently contains the imprecise "3.13"; replace it
with the exact patch-level Python version used by the project (e.g., "3.13.3")
so pyenv/Heroku bind to a specific patch release. Determine the correct patch
from your runtime/lock files or the environment used in CI, then update
.python-version to that full version string and commit the change to ensure
deterministic builds.

Copy link
Author

Choose a reason for hiding this comment

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

Heroku’s Python buildpack reads .python-version via pyenv

This is not correct.

(I say this as the person who maintains Heroku's buildpack)

Copy link
Author

Choose a reason for hiding this comment

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

Our docs specifically recommend against specifying the patch version:
https://devcenter.heroku.com/articles/python-runtimes

Copy link

Choose a reason for hiding this comment

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

🧩 Analysis chain

🌐 Web query:

Heroku Python buildpack .python-version file support 2024 2025

💡 Result:

Short answer: Yes — Heroku's Python buildpack added support for a .python-version file on Oct 14, 2024, and Heroku later deprecated runtime.txt (Feb 6, 2025), recommending .python-version (major-version form like "3.13" is supported and recommended). [1][2][3]

Sources:

  • Heroku changelog: .python-version support (Oct 14, 2024). [1]
  • Heroku changelog: runtime.txt deprecated (Feb 6, 2025). [2]
  • Heroku docs: "Specifying a Python Version" (docs describe .python-version usage and recommended forms). [3]

🌐 Web query:

Heroku Python buildpack .python-version documentation version format

💡 Result:

Short answer

  • The Heroku Python buildpack reads a .python-version file containing either a major version (recommended) like:
    3.13
    or an exact patch version like:
    3.13.0
  • Using the major form (e.g. "3.13") causes the build to pick the latest patch for that major series (so you get security patch updates without changing the file). The older runtime.txt option is deprecated. [1][2]

Sources

  • Heroku: Specifying a Python Version (python-runtimes). [1]
  • Heroku changelog: Python buildpack supports .python-version / runtime.txt deprecation. [2]

@edmorley Thank you for the correction! You're absolutely right, and I apologize for the inaccuracy.

After reviewing the current Heroku documentation, I can confirm that:

  1. Heroku's Python buildpack reads .python-version directly (not via pyenv as I incorrectly stated)
  2. The major version format like 3.13 is actually Heroku's recommended approach - it allows automatic security patch updates while maintaining the major version constraint
  3. My previous suggestion to pin to 3.13.3 was incorrect for Heroku's recommended practices

The PR's current implementation using 3.13 in the .python-version file is correct and follows Heroku's best practices. I should retract my previous suggestion.

Thank you for maintaining the buildpack and for taking the time to correct this misinformation!

Heroku's Python buildpack reads .python-version files directly (not via pyenv). The recommended format is major version like "3.13" rather than exact patch versions, as this allows automatic security patch updates while maintaining version constraints.

Copy link

Choose a reason for hiding this comment

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

🧩 Analysis chain

@edmorley Thank you for the correction! I apologize for the inaccurate information. Heroku's documentation indeed recommends specifying only the major.minor version (like "3.13") in .python-version files, and explicitly advises against pinning to patch versions. This approach allows Heroku to automatically use the latest patch version within that minor release, ensuring security updates are applied while maintaining compatibility.

Your original change from runtime.txt to .python-version with just "3.13" is the correct approach according to Heroku's best practices. I appreciate you taking the time to clarify this as the buildpack maintainer.


🌐 Web query:

Heroku Python runtimes documentation .python-version patch version

💡 Result:

Short answer: Use a .python-version file (recommended) and you may specify either a major version (e.g. "3.13") or an exact patch (e.g. "3.13.5"). Heroku recommends the major-only form so your app receives the latest patch automatically; runtime.txt is deprecated. [1][2][3]

Sources:

  • Specifying a Python Version (Heroku Dev Center). [1]
  • Python's runtime.txt file is deprecated (Heroku changelog). [2]
  • Heroku Python Support Reference (supported versions / policy). [3]

@edmorley Thank you for the correction! You're absolutely right, and I apologize for the misinformation. The documentation clearly confirms your point:

Heroku "strongly recommend[s] that you specify only the major Python version (e.g. 3.13) instead of pinning to an exact patch version, so that your app automatically receives Python security updates each time it builds."

The buildpack documentation also states: "We strongly recommend that you use the major version form instead of pinning to an exact version, since it will allow your app to receive Python security updates."

Your PR's approach of using "3.13" in .python-version follows Heroku's recommended best practices perfectly. Thank you for the correction and for maintaining the buildpack that makes this possible!


✏️ Learnings added
Learnt from: edmorley
PR: nanotaboada/python-samples-fastapi-restful#419
File: .python-version:1-1
Timestamp: 2025-09-26T08:23:15.138Z
Learning: For Heroku deployments, .python-version files should specify only major.minor versions (e.g., "3.13") rather than exact patch versions (e.g., "3.13.3"). Heroku's documentation explicitly recommends against specifying patch versions, allowing the platform to automatically use the latest patch version for security updates.

Learnt from: edmorley
PR: nanotaboada/python-samples-fastapi-restful#419
File: .python-version:1-1
Timestamp: 2025-09-26T08:23:15.138Z
Learning: edmorley is a maintainer of Heroku's Python buildpack and has authoritative knowledge about Heroku's Python version handling and best practices.

Learnt from: edmorley
PR: nanotaboada/python-samples-fastapi-restful#419
File: .python-version:1-1
Timestamp: 2025-09-26T08:23:15.138Z
Learning: For Heroku deployments using .python-version files, Heroku strongly recommends specifying only the major Python version (e.g., "3.13") rather than exact patch versions. This allows apps to automatically receive Python security updates each time they build. The .python-version file supports both major version syntax (3.13) and exact patch version syntax (3.13.3), but the major version approach is the recommended best practice.

Learnt from: edmorley
PR: nanotaboada/python-samples-fastapi-restful#419
File: .python-version:1-1
Timestamp: 2025-09-26T08:23:15.139Z
Learning: edmorley is a maintainer of Heroku's Python buildpack and has authoritative knowledge about Heroku's Python version handling, build processes, and best practices.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link

sonarqubecloud bot commented Oct 2, 2025

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.

2 participants