From 84c9fc4a9972065a6a02a6b692b3412cd317b984 Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Wed, 8 Oct 2025 23:07:28 +1300 Subject: [PATCH 1/3] Support Python 3.14 --- README.md | 2 +- docs/example-usage.md | 2 +- tests/conftest.py | 2 +- tests/usethis/_core/test_core_ci.py | 8 ++++---- tests/usethis/_tool/impl/test_pytest.py | 10 +++++----- .../_ui/interface/maximal_bitbucket_pipelines.yml | 8 ++++---- tests/usethis/_ui/interface/test_ci.py | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 860811ac..936861d6 100644 --- a/README.md +++ b/README.md @@ -154,8 +154,8 @@ $ uvx usethis ci bitbucket ✔ Writing 'bitbucket-pipelines.yml'. ✔ Adding cache 'uv' definition to 'bitbucket-pipelines.yml'. ✔ Adding 'Run Ruff' to default pipeline in 'bitbucket-pipelines.yml'. -✔ Adding 'Test on 3.12' to default pipeline in 'bitbucket-pipelines.yml'. ✔ Adding 'Test on 3.13' to default pipeline in 'bitbucket-pipelines.yml'. +✔ Adding 'Test on 3.14' to default pipeline in 'bitbucket-pipelines.yml'. ☐ Run your pipeline via the Bitbucket website. ``` diff --git a/docs/example-usage.md b/docs/example-usage.md index 48bbc0f3..4e0276d4 100644 --- a/docs/example-usage.md +++ b/docs/example-usage.md @@ -58,7 +58,7 @@ $ uvx usethis ci bitbucket ✔ Writing 'bitbucket-pipelines.yml'. ✔ Adding cache 'uv' definition to 'bitbucket-pipelines.yml'. ✔ Adding 'Run Ruff' to default pipeline in 'bitbucket-pipelines.yml'. -✔ Adding 'Test on 3.12' to default pipeline in 'bitbucket-pipelines.yml'. ✔ Adding 'Test on 3.13' to default pipeline in 'bitbucket-pipelines.yml'. +✔ Adding 'Test on 3.14' to default pipeline in 'bitbucket-pipelines.yml'. ☐ Run your pipeline via the Bitbucket website. ``` diff --git a/tests/conftest.py b/tests/conftest.py index 113d22fc..f989a410 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -21,7 +21,7 @@ def _uv_init_dir(tmp_path_factory: pytest.TempPathFactory) -> Path: "--python", # Deliberately kept at at a version other than the latest version to # check range checks e.g. for Bitbucket pipelines matrixes. - "3.12", + "3.13", "--vcs", "none", ], diff --git a/tests/usethis/_core/test_core_ci.py b/tests/usethis/_core/test_core_ci.py index 99ebc303..0c357fcd 100644 --- a/tests/usethis/_core/test_core_ci.py +++ b/tests/usethis/_core/test_core_ci.py @@ -473,7 +473,7 @@ def test_unsupported_python_version_removed(self, uv_init_dir: Path): (uv_init_dir / "pyproject.toml").write_text( """\ [project] -requires-python = ">=3.12,<3.13" +requires-python = ">=3.13,<3.14" """ ) (uv_init_dir / "bitbucket-pipelines.yml").write_text( @@ -482,11 +482,11 @@ def test_unsupported_python_version_removed(self, uv_init_dir: Path): pipelines: default: - step: - name: Test on 3.11 + name: Test on 3.12 script: - echo 'Hello, world!' - step: - name: Test on 3.12 + name: Test on 3.13 script: - echo 'Hello, world!' """ @@ -498,7 +498,7 @@ def test_unsupported_python_version_removed(self, uv_init_dir: Path): # Assert contents = (uv_init_dir / "bitbucket-pipelines.yml").read_text() - assert "Test on 3.11" not in contents + assert "Test on 3.12" not in contents class TestRemove: class TestPyproject: diff --git a/tests/usethis/_tool/impl/test_pytest.py b/tests/usethis/_tool/impl/test_pytest.py index 6bcbe76c..99d2c4db 100644 --- a/tests/usethis/_tool/impl/test_pytest.py +++ b/tests/usethis/_tool/impl/test_pytest.py @@ -41,19 +41,19 @@ def test_new_file(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]): pipelines: default: - step: - name: Test on 3.12 + name: Test on 3.13 caches: - uv script: - *install-uv - - uv run --python 3.12 pytest -x --junitxml=test-reports/report.xml + - uv run --python 3.13 pytest -x --junitxml=test-reports/report.xml - step: - name: Test on 3.13 + name: Test on 3.14 caches: - uv script: - *install-uv - - uv run --python 3.13 pytest -x --junitxml=test-reports/report.xml + - uv run --python 3.14 pytest -x --junitxml=test-reports/report.xml """ ) @@ -62,8 +62,8 @@ def test_new_file(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]): assert out == ( "✔ Writing 'bitbucket-pipelines.yml'.\n" "✔ Adding cache 'uv' definition to 'bitbucket-pipelines.yml'.\n" - "✔ Adding 'Test on 3.12' to default pipeline in 'bitbucket-pipelines.yml'.\n" "✔ Adding 'Test on 3.13' to default pipeline in 'bitbucket-pipelines.yml'.\n" + "✔ Adding 'Test on 3.14' to default pipeline in 'bitbucket-pipelines.yml'.\n" ) def test_remove_old_steps( diff --git a/tests/usethis/_ui/interface/maximal_bitbucket_pipelines.yml b/tests/usethis/_ui/interface/maximal_bitbucket_pipelines.yml index 8793b749..baf59982 100644 --- a/tests/usethis/_ui/interface/maximal_bitbucket_pipelines.yml +++ b/tests/usethis/_ui/interface/maximal_bitbucket_pipelines.yml @@ -20,16 +20,16 @@ pipelines: - *install-uv - uv run pre-commit run --all-files - step: - name: Test on 3.12 + name: Test on 3.13 caches: - uv script: - *install-uv - - uv run --python 3.12 pytest -x --junitxml=test-reports/report.xml + - uv run --python 3.13 pytest -x --junitxml=test-reports/report.xml - step: - name: Test on 3.13 + name: Test on 3.14 caches: - uv script: - *install-uv - - uv run --python 3.13 pytest -x --junitxml=test-reports/report.xml + - uv run --python 3.14 pytest -x --junitxml=test-reports/report.xml diff --git a/tests/usethis/_ui/interface/test_ci.py b/tests/usethis/_ui/interface/test_ci.py index 6ff26a5c..c365dd22 100644 --- a/tests/usethis/_ui/interface/test_ci.py +++ b/tests/usethis/_ui/interface/test_ci.py @@ -21,7 +21,7 @@ def test_readme_example(self, tmp_path: Path): (tmp_path / "pyproject.toml").write_text( """\ [project] -requires-python = ">=3.12" +requires-python = ">=3.13" """ ) @@ -39,8 +39,8 @@ def test_readme_example(self, tmp_path: Path): ✔ Adding cache 'uv' definition to 'bitbucket-pipelines.yml'. ✔ Adding 'Run Ruff' to default pipeline in 'bitbucket-pipelines.yml'. ✔ Adding 'Run Ruff Formatter' to default pipeline in 'bitbucket-pipelines.yml'. -✔ Adding 'Test on 3.12' to default pipeline in 'bitbucket-pipelines.yml'. ✔ Adding 'Test on 3.13' to default pipeline in 'bitbucket-pipelines.yml'. +✔ Adding 'Test on 3.14' to default pipeline in 'bitbucket-pipelines.yml'. ☐ Run your pipeline via the Bitbucket website. """ ) From 62359e6a494388450e3735f81d30ea635860e777 Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Wed, 8 Oct 2025 23:34:55 +1300 Subject: [PATCH 2/3] Move to using pinned version bounds in tests instead of bumping --- tests/usethis/_core/test_core_ci.py | 6 +++++- tests/usethis/_tool/impl/test_pytest.py | 11 ++++++----- .../_ui/interface/maximal_bitbucket_pipelines.yml | 8 ++++---- tests/usethis/_ui/interface/test_ci.py | 4 ++-- tests/usethis/_ui/interface/test_interface_ci.py | 4 ++++ 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tests/usethis/_core/test_core_ci.py b/tests/usethis/_core/test_core_ci.py index 0c357fcd..c7e7d125 100644 --- a/tests/usethis/_core/test_core_ci.py +++ b/tests/usethis/_core/test_core_ci.py @@ -440,8 +440,12 @@ def test_mentioned_in_file( (uv_init_dir / "tests").mkdir() (uv_init_dir / "tests" / "conftest.py").touch() - # Act with change_cwd(uv_init_dir), files_manager(): + PyprojectTOMLManager()[["project"]]["requires-python"] = ( + ">=3.12,<3.14" + ) + + # Act use_ci_bitbucket() # Assert diff --git a/tests/usethis/_tool/impl/test_pytest.py b/tests/usethis/_tool/impl/test_pytest.py index 99d2c4db..cbb992fb 100644 --- a/tests/usethis/_tool/impl/test_pytest.py +++ b/tests/usethis/_tool/impl/test_pytest.py @@ -16,6 +16,7 @@ class TestUpdateBitbucketSteps: def test_new_file(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]): with change_cwd(uv_init_dir), files_manager(): # Arrange + PyprojectTOMLManager()[["project"]]["requires-python"] = ">=3.12,<3.14" add_placeholder_step_in_default(report_placeholder=False) (uv_init_dir / "pytest.ini").touch() @@ -41,19 +42,19 @@ def test_new_file(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]): pipelines: default: - step: - name: Test on 3.13 + name: Test on 3.12 caches: - uv script: - *install-uv - - uv run --python 3.13 pytest -x --junitxml=test-reports/report.xml + - uv run --python 3.12 pytest -x --junitxml=test-reports/report.xml - step: - name: Test on 3.14 + name: Test on 3.13 caches: - uv script: - *install-uv - - uv run --python 3.14 pytest -x --junitxml=test-reports/report.xml + - uv run --python 3.13 pytest -x --junitxml=test-reports/report.xml """ ) @@ -62,8 +63,8 @@ def test_new_file(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]): assert out == ( "✔ Writing 'bitbucket-pipelines.yml'.\n" "✔ Adding cache 'uv' definition to 'bitbucket-pipelines.yml'.\n" + "✔ Adding 'Test on 3.12' to default pipeline in 'bitbucket-pipelines.yml'.\n" "✔ Adding 'Test on 3.13' to default pipeline in 'bitbucket-pipelines.yml'.\n" - "✔ Adding 'Test on 3.14' to default pipeline in 'bitbucket-pipelines.yml'.\n" ) def test_remove_old_steps( diff --git a/tests/usethis/_ui/interface/maximal_bitbucket_pipelines.yml b/tests/usethis/_ui/interface/maximal_bitbucket_pipelines.yml index baf59982..8793b749 100644 --- a/tests/usethis/_ui/interface/maximal_bitbucket_pipelines.yml +++ b/tests/usethis/_ui/interface/maximal_bitbucket_pipelines.yml @@ -20,16 +20,16 @@ pipelines: - *install-uv - uv run pre-commit run --all-files - step: - name: Test on 3.13 + name: Test on 3.12 caches: - uv script: - *install-uv - - uv run --python 3.13 pytest -x --junitxml=test-reports/report.xml + - uv run --python 3.12 pytest -x --junitxml=test-reports/report.xml - step: - name: Test on 3.14 + name: Test on 3.13 caches: - uv script: - *install-uv - - uv run --python 3.14 pytest -x --junitxml=test-reports/report.xml + - uv run --python 3.13 pytest -x --junitxml=test-reports/report.xml diff --git a/tests/usethis/_ui/interface/test_ci.py b/tests/usethis/_ui/interface/test_ci.py index c365dd22..b1dbe2cb 100644 --- a/tests/usethis/_ui/interface/test_ci.py +++ b/tests/usethis/_ui/interface/test_ci.py @@ -21,7 +21,7 @@ def test_readme_example(self, tmp_path: Path): (tmp_path / "pyproject.toml").write_text( """\ [project] -requires-python = ">=3.13" +requires-python = ">=3.12,<3.14" """ ) @@ -39,8 +39,8 @@ def test_readme_example(self, tmp_path: Path): ✔ Adding cache 'uv' definition to 'bitbucket-pipelines.yml'. ✔ Adding 'Run Ruff' to default pipeline in 'bitbucket-pipelines.yml'. ✔ Adding 'Run Ruff Formatter' to default pipeline in 'bitbucket-pipelines.yml'. +✔ Adding 'Test on 3.12' to default pipeline in 'bitbucket-pipelines.yml'. ✔ Adding 'Test on 3.13' to default pipeline in 'bitbucket-pipelines.yml'. -✔ Adding 'Test on 3.14' to default pipeline in 'bitbucket-pipelines.yml'. ☐ Run your pipeline via the Bitbucket website. """ ) diff --git a/tests/usethis/_ui/interface/test_interface_ci.py b/tests/usethis/_ui/interface/test_interface_ci.py index 38a9746c..4d64e97d 100644 --- a/tests/usethis/_ui/interface/test_interface_ci.py +++ b/tests/usethis/_ui/interface/test_interface_ci.py @@ -4,6 +4,7 @@ from typer.testing import CliRunner from usethis._config import usethis_config +from usethis._integrations.file.pyproject_toml.io_ import PyprojectTOMLManager from usethis._test import change_cwd from usethis._ui.app import app as main_app from usethis._ui.interface.ci import app @@ -46,6 +47,9 @@ def test_maximal_config(self, uv_init_repo_dir: Path): runner = CliRunner() with change_cwd(uv_init_repo_dir): # Arrange + with PyprojectTOMLManager() as mgr: + mgr[["project"]]["requires-python"] = ">=3.12,<3.14" + for tool_command in ALL_TOOL_COMMANDS: if not usethis_config.offline: result = runner.invoke(main_app, ["tool", tool_command]) From 9228c51858967763c6cce760c8c96c767af36522 Mon Sep 17 00:00:00 2001 From: Nathan McDougall Date: Wed, 8 Oct 2025 23:46:53 +1300 Subject: [PATCH 3/3] Bump Python version in SonarQube test --- .../_integrations/sonarqube/test_sonarqube_config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/usethis/_integrations/sonarqube/test_sonarqube_config.py b/tests/usethis/_integrations/sonarqube/test_sonarqube_config.py index da7d3414..51428813 100644 --- a/tests/usethis/_integrations/sonarqube/test_sonarqube_config.py +++ b/tests/usethis/_integrations/sonarqube/test_sonarqube_config.py @@ -34,7 +34,7 @@ def test_dump_file(self, tmp_path: Path): # Assert assert result == contents - def test_file_not_exists(self, uv_init_dir: Path): + def test_file_doesnt_exist(self, uv_init_dir: Path): # If the file does not exist, we should construct based on information in # the repo. @@ -46,7 +46,7 @@ def test_file_not_exists(self, uv_init_dir: Path): PyprojectTOMLManager().set_value( keys=["tool", "coverage", "xml", "output"], value="coverage.xml" ) - uv_python_pin("3.12") + uv_python_pin("3.13") content = (uv_init_dir / "pyproject.toml").read_text() assert "xml" in content @@ -60,7 +60,7 @@ def test_file_not_exists(self, uv_init_dir: Path): == """\ sonar.projectKey=foobar sonar.language=py -sonar.python.version=3.12 +sonar.python.version=3.13 sonar.sources=./src sonar.tests=./tests sonar.python.coverage.reportPaths=coverage.xml