Skip to content

Conversation

@edmorley
Copy link
Member

We recommend that apps use a .python-version file to specify their Python version. However, as seen on Honeycomb after #1904, a small number of apps in the wild have spelt the file incorrectly - and sometimes with names that look very similar to the correct name, so the mistake would be easy to miss.

Some of the mistakes seen include:

  • Omitting the leading . in the filename.
  • Adding a file extension such as .txt.
  • Using an underscore or a period instead of the hyphen.
  • Having trailing whitespace in the filename.

The metrics show that some apps have both a correctly spelled file and an incorrectly spelled one, which I suspect would lead to a confusing UX if the wrong file was ever updated ("why isn't Heroku using the Python version I've specified?") - particularly in the case where the user doesn't have dotfiles visible in eg Finder and the spelling mistake was omitting the leading .. As such, we still error if a misspelled file is found, even if a correctly named one also exists.

GUS-W-19687420.

@edmorley edmorley self-assigned this Nov 20, 2025
We recommend that apps use a `.python-version` file to specify their
Python version. However, as seen on Honeycomb after #1904, a small
number of apps in the wild have spelt the file incorrectly - and
sometimes with names that look very similar to the correct name, so
the mistake would be easy to miss.

Some of the mistakes seen include:
- Omitting the leading `.` in the filename.
- Adding a file extension such as `.txt`.
- Using an underscore or a period instead of the hyphen.
- Having trailing whitespace in the filename.

The metrics show that some apps have both a correctly spelled file
and an incorrectly spelled one, which I suspect would lead to a
confusing UX if the wrong file was ever updated ("why isn't Heroku
using the Python version I've specified?") - particularly in the
case where the user doesn't have dotfiles visible in eg Finder
and the spelling mistake was omitting the leading `.`. As such, we
still error if a misspelled file is found, even if a correctly
named one also exists.

GUS-W-19687420.
@edmorley edmorley force-pushed the misspelled-python-version-file branch from 1abbb14 to 5fa38f6 Compare November 20, 2025 12:11
@edmorley edmorley marked this pull request as ready for review November 20, 2025 12:14
@edmorley edmorley requested a review from a team as a code owner November 20, 2025 12:14
@dzuelke
Copy link
Contributor

dzuelke commented Nov 20, 2025

Would it not make sense to do a case-insensitive check for the given variants?

@edmorley
Copy link
Member Author

edmorley commented Nov 20, 2025

@dzuelke I'd thought about doing so initially, however:

  • it kinda gets annoying since it would mean using a find based approach with regex (with the potential for more false positives, given we'd end up with permutations like python_version.py which is technically a valid Python module name)
  • the metrics over the last 60 days showed zero misspellings with capitalisation errors in the stem of the filename (the only capitals were .TXT. The .Python-version I added in this PR was a "just in case" not seen in the wild)

I was thinking I'd try this and see what the metrics show over the next few months.

Also longer term I think I may end up making .python-version mandatory for all apps, at which point the error message for ".python-version not found" would likely include a directory listing of the app root, which would solve the issue a different way (and mean I remove the misspelling error variant).

@dzuelke
Copy link
Contributor

dzuelke commented Nov 20, 2025

You could use shopt -s nocaseglob, no?

@edmorley
Copy link
Member Author

You could use shopt -s nocaseglob, no?

No, it doesn't work when doing -f matches with test.

@edmorley edmorley merged commit 2bf1d7d into main Nov 20, 2025
6 checks passed
@edmorley edmorley deleted the misspelled-python-version-file branch November 20, 2025 13:57
@heroku-linguist heroku-linguist bot mentioned this pull request Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants