Skip to content

Commit d99a337

Browse files
authored
Add metrics for misspelled .python-version files (#1904)
Record the names of files similar to .python-version in the root of the app, to determine how often that file is misspelled, as a temporary first step before deciding whether to add a new warning/error (and if so, which for which misspelled filenames it should check). GUS-W-19271516.
1 parent 2e852f4 commit d99a337

5 files changed

Lines changed: 15 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [Unreleased]
44

5+
- Added metrics for misspelled `.python-version` files. ([#1904](https://github.com/heroku/heroku-buildpack-python/pull/1904))
56

67
## [v308] - 2025-09-19
78

lib/python_version.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ function python_version::read_requested_python_version() {
5050
declare -n origin="${5}"
5151
local contents
5252

53+
# Record the names of files similar to .python-version in the root of the app, to determine
54+
# how often that file is misspelled, as a temporary first step before deciding whether to add
55+
# a new warning/error (and if so, which for which misspelled filenames it should check).
56+
local python_version_files
57+
python_version_files="$(
58+
find . -maxdepth 1 -type f -iregex '\./\.?python.?version.*' -printf '%P\n' | sort | tr '\n' ',' || true
59+
)"
60+
if [[ -n "${python_version_files}" ]]; then
61+
build_data::set_string "python_version_files" "${python_version_files}"
62+
fi
63+
5364
local runtime_txt_path="${build_dir}/runtime.txt"
5465
if [[ -f "${runtime_txt_path}" ]]; then
5566
contents="$(utils::read_file_with_special_chars_substituted "${runtime_txt_path}")"

spec/hatchet/pip_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
remote: "pre_compile_hook": false,
7373
remote: "python_install_duration": [0-9.]+,
7474
remote: "python_version": "#{DEFAULT_PYTHON_FULL_VERSION}",
75+
remote: "python_version_files": ".python-version,",
7576
remote: "python_version_major": "3.13",
7677
remote: "python_version_origin": ".python-version",
7778
remote: "python_version_outdated": false,

spec/hatchet/poetry_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
remote: "pre_compile_hook": false,
7575
remote: "python_install_duration": [0-9.]+,
7676
remote: "python_version": "#{DEFAULT_PYTHON_FULL_VERSION}",
77+
remote: "python_version_files": ".python-version,",
7778
remote: "python_version_major": "3.13",
7879
remote: "python_version_origin": ".python-version",
7980
remote: "python_version_outdated": false,

spec/hatchet/uv_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
remote: "pre_compile_hook": false,
8080
remote: "python_install_duration": [0-9.]+,
8181
remote: "python_version": "#{DEFAULT_PYTHON_FULL_VERSION}",
82+
remote: "python_version_files": ".python-version,",
8283
remote: "python_version_major": "3.13",
8384
remote: "python_version_origin": ".python-version",
8485
remote: "python_version_outdated": false,

0 commit comments

Comments
 (0)