René's URL Explorer Experiment


Title: fix(providers/uv): treat uv.lock as optional by bearomorphism · Pull Request #1979 · commitizen-tools/commitizen · GitHub

Open Graph Title: fix(providers/uv): treat uv.lock as optional by bearomorphism · Pull Request #1979 · commitizen-tools/commitizen

X Title: fix(providers/uv): treat uv.lock as optional by bearomorphism · Pull Request #1979 · commitizen-tools/commitizen

Description: Description Closes #1383. Why UvProvider.set_lock_version() unconditionally read uv.lock via self.lock_file.read_text(), so cz bump crashed with FileNotFoundError: [Errno 2] No such file or directory: 'uv.lock' whenever the lock had not been written yet. Two real-world reproducers: A freshly initialised uv project that has never had uv sync run (the original reporter's reproduction, posted in the issue thread). A uv workspace member: the lock lives at the workspace root, not next to the package's own pyproject.toml. A user reported this in a follow-up comment using uv 0.7.9 / cz 4.8.0. The maintainer (@Lee-W) confirmed in the issue thread: "hmmm... I thought we have it long ago. yep, we'll definitely need it." What changed File Change commitizen/providers/uv_provider.py set_version() now wraps the set_lock_version(version) call in if self.lock_file.is_file():, mirroring the convention used by cargo_provider.py:42 and npm_provider.py:53,62. set_lock_version() itself is unchanged so external callers that already verified the lock exists keep working. tests/providers/test_uv_provider.py New test_uv_provider_without_lock_file — creates a pyproject.toml without a sibling uv.lock, runs set_version("100.100.100"), asserts pyproject.toml was updated and no uv.lock was created. How it works The guard uses Path.is_file(), not Path.exists(). exists() is also true for directories and symlinks-to-non-files, both of which would still trip read_text(). The cargo and npm providers already make this distinction; the uv provider was the outlier. The guard is hoisted to set_version() rather than placed at the top of set_lock_version(). This matches cargo_provider.py's structure and means the lock-rewrite path can keep its precondition: "if you call set_lock_version, the lock must exist." For uv workspace members the lock is at the workspace root, not next to the package. The lock_file property here resolves to the cwd-relative uv.lock, which won't exist for a workspace member running from its own subdirectory; the is_file() guard skips the rewrite cleanly. A future PR could add proper workspace-root resolution, but that's a feature, not part of this fix — uv reconciles the lock on the next uv sync either way. TOCTOU race (lock created between is_file() and read_text()) is benign — the subsequent read_text() would simply succeed with the new content. Backward compatibility Existing path (lock present, single-package uv project) is exercised by the unchanged test_uv_provider[hyphenated|underscore] and produces byte-identical output. No public API change; set_lock_version() keeps the same signature. Checklist I have read the contributing guidelines Was generative AI tooling used to co-author this PR? Yes (please specify the tool below) Generated-by: Claude following the guidelines Code Changes Add test cases to all the changes you introduce (1 new regression test) Run uv run poe all locally to ensure this change passes linter check and tests (poe lint clean; 3/3 uv_provider tests pass — 2 existing + 1 new) Manually test the changes (see "Steps to Test" below for the issue reporter's exact reproduction script) Update the documentation for the changes (no doc change required — the lock-handling behaviour is internal) Expected Behavior Scenario Before this PR After this PR Fresh uv project, no uv.lock yet cz bump crashes with FileNotFoundError: 'uv.lock' pyproject.toml is updated, no lock written, exit 0. uv workspace member running from subdirectory Same FileNotFoundError Same — package's pyproject.toml updated, lock-rewrite skipped (workspace root will be reconciled by next uv sync). Single-package project with a populated uv.lock Both files updated Both files updated (unchanged). uv.lock is a directory or symlink to a non-file Crashes with the same error Skipped via is_file() (matches cargo/npm convention). Steps to Test This Pull Request git fetch fork fix/1383-uv-lock-optional git checkout fork/fix/1383-uv-lock-optional # 1. Targeted regression test (3 cases). uv run pytest tests/providers/test_uv_provider.py -v # expected: 3 passed # 2. Reproduce the original bug, then verify the fix (matches the issue reporter's script). mkdir -p /tmp/cz-1383 && cd /tmp/cz-1383 git init -q uv init --quiet uv run cz init --no-prompt # or follow the prompts; pick `uv` as the version provider sed -i.bak 's/pep621/uv/' pyproject.toml git add . && git -c user.email=a@b -c user.name=t commit -qm "feat: a" # On master this would now crash. On this PR it should succeed: uv run cz bump --yes test -f uv.lock && echo "lock exists" || echo "no lock — expected" grep '^version' pyproject.toml # should show the bumped version Additional Context Surfaced while triaging open issues in #1976 (round 3). Switched from Path.exists() to Path.is_file() in fixup commit f204942e after GitHub Copilot's review noted that the existing convention in cargo_provider.py:42 and npm_provider.py:53,62 is is_file() (and that exists() would still trip if the lock path happened to be a directory). The issue had been open for 11 months and was already labelled good first issue + wait-for-implementation; the previously assigned contributor confirmed they were happy for someone else to take it over.

Open Graph Description: Description Closes #1383. Why UvProvider.set_lock_version() unconditionally read uv.lock via self.lock_file.read_text(), so cz bump crashed with FileNotFoundError: [Errno 2] No such file or directo...

X Description: Description Closes #1383. Why UvProvider.set_lock_version() unconditionally read uv.lock via self.lock_file.read_text(), so cz bump crashed with FileNotFoundError: [Errno 2] No such file or directo...

Opengraph URL: https://github.com/commitizen-tools/commitizen/pull/1979

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:ffd95db7-9620-1e4e-7d27-d8ce786450a4
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idEA94:171DD4:1BE6C6:256DC3:6A525557
html-safe-noncec7753d3a60416c0aee4df6cda596061fd6112724b475edd65b4c8a58bc4ee66a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTk0OjE3MURENDoxQkU2QzY6MjU2REMzOjZBNTI1NTU3IiwidmlzaXRvcl9pZCI6IjY0MzI1NDg3NDgzNTg5OTczMzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacc1dfb1fe9c0ed97485bd2d925fd43edd013ace98a37bc34f725e963aac06876d
hovercard-subject-tagpull_request:3654776687
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/commitizen-tools/commitizen/pull/1979/files
twitter:imagehttps://avatars.githubusercontent.com/u/26526132?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/26526132?s=400&v=4
og:image:altDescription Closes #1383. Why UvProvider.set_lock_version() unconditionally read uv.lock via self.lock_file.read_text(), so cz bump crashed with FileNotFoundError: [Errno 2] No such file or directo...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git
octolytics-dimension-user_id62252524
octolytics-dimension-user_logincommitizen-tools
octolytics-dimension-repository_id106127589
octolytics-dimension-repository_nwocommitizen-tools/commitizen
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id106127589
octolytics-dimension-repository_network_root_nwocommitizen-tools/commitizen
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7aed05249554b889eb33d002851a973eebcc7e91
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/commitizen-tools/commitizen/pull/1979/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcommitizen-tools%2Fcommitizen%2Fpull%2F1979%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcommitizen-tools%2Fcommitizen%2Fpull%2F1979%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=commitizen-tools%2Fcommitizen
Reloadhttps://github.com/commitizen-tools/commitizen/pull/1979/files
Reloadhttps://github.com/commitizen-tools/commitizen/pull/1979/files
Reloadhttps://github.com/commitizen-tools/commitizen/pull/1979/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1979/files
commitizen-tools https://github.com/commitizen-tools
commitizenhttps://github.com/commitizen-tools/commitizen
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1979/files
Notifications https://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen
Fork 344 https://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen
Star 3.5k https://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen
Code https://github.com/commitizen-tools/commitizen
Issues 117 https://github.com/commitizen-tools/commitizen/issues
Pull requests 45 https://github.com/commitizen-tools/commitizen/pulls
Discussions https://github.com/commitizen-tools/commitizen/discussions
Actions https://github.com/commitizen-tools/commitizen/actions
Projects https://github.com/commitizen-tools/commitizen/projects
Security and quality 0 https://github.com/commitizen-tools/commitizen/security
Insights https://github.com/commitizen-tools/commitizen/pulse
Code https://github.com/commitizen-tools/commitizen
Issues https://github.com/commitizen-tools/commitizen/issues
Pull requests https://github.com/commitizen-tools/commitizen/pulls
Discussions https://github.com/commitizen-tools/commitizen/discussions
Actions https://github.com/commitizen-tools/commitizen/actions
Projects https://github.com/commitizen-tools/commitizen/projects
Security and quality https://github.com/commitizen-tools/commitizen/security
Insights https://github.com/commitizen-tools/commitizen/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fcommitizen-tools%2Fcommitizen%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen%2Fissues%2Fnew%2Fchoose
bearomorphismhttps://github.com/bearomorphism
commitizen-tools:masterhttps://github.com/commitizen-tools/commitizen/tree/master
bearomorphism:fix/1383-uv-lock-optionalhttps://github.com/bearomorphism/commitizen/tree/fix/1383-uv-lock-optional
Conversation 4 https://github.com/commitizen-tools/commitizen/pull/1979
Commits 2 https://github.com/commitizen-tools/commitizen/pull/1979/commits
Checks 20 https://github.com/commitizen-tools/commitizen/pull/1979/checks
Files changed https://github.com/commitizen-tools/commitizen/pull/1979/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1979/files
fix(providers/uv): treat uv.lock as optional https://github.com/commitizen-tools/commitizen/pull/1979/files#top
Show all changes 2 commits https://github.com/commitizen-tools/commitizen/pull/1979/files
5392da8 fix(providers/uv): treat uv.lock as optional bearomorphism May 9, 2026 https://github.com/commitizen-tools/commitizen/pull/1979/commits/5392da8669b5afe8c924ac1366f0281bbe61ef55
f204942 fix(providers/uv): use `is_file()` to match cargo/npm convention bearomorphism May 9, 2026 https://github.com/commitizen-tools/commitizen/pull/1979/commits/f204942e770485e94dc50c25daf1027c4c786c7b
Clear filters https://github.com/commitizen-tools/commitizen/pull/1979/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1979/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1979/files
uv_provider.py https://github.com/commitizen-tools/commitizen/pull/1979/files#diff-95643cbadfdb023421cfa98eb5feb466b81f289b0ff52b527eae1be5e144123f
test_uv_provider.py https://github.com/commitizen-tools/commitizen/pull/1979/files#diff-029196316f9bffe57f6b6d47b6d40ddbb0f4b91a44071e2eb222d2e46f86073d
commitizen/providers/uv_provider.pyhttps://github.com/commitizen-tools/commitizen/pull/1979/files#diff-95643cbadfdb023421cfa98eb5feb466b81f289b0ff52b527eae1be5e144123f
View file https://github.com/commitizen-tools/commitizen/blob/f204942e770485e94dc50c25daf1027c4c786c7b/commitizen/providers/uv_provider.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/commitizen-tools/commitizen/pull/1979/{{ revealButtonHref }}
https://github.com/commitizen-tools/commitizen/pull/1979/files#diff-95643cbadfdb023421cfa98eb5feb466b81f289b0ff52b527eae1be5e144123f
Lee-Whttps://github.com/Lee-W
May 11, 2026https://github.com/commitizen-tools/commitizen/pull/1979/files#r3219711608
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1979/files
https://github.com/commitizen-tools/commitizen/pull/1979/files#diff-95643cbadfdb023421cfa98eb5feb466b81f289b0ff52b527eae1be5e144123f
tests/providers/test_uv_provider.pyhttps://github.com/commitizen-tools/commitizen/pull/1979/files#diff-029196316f9bffe57f6b6d47b6d40ddbb0f4b91a44071e2eb222d2e46f86073d
View file https://github.com/commitizen-tools/commitizen/blob/f204942e770485e94dc50c25daf1027c4c786c7b/tests/providers/test_uv_provider.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/commitizen-tools/commitizen/pull/1979/{{ revealButtonHref }}
https://github.com/commitizen-tools/commitizen/pull/1979/files#diff-029196316f9bffe57f6b6d47b6d40ddbb0f4b91a44071e2eb222d2e46f86073d
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1979/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.