Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -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.

1 change: 0 additions & 1 deletion runtime.txt

This file was deleted.

Loading