Skip to content

Make uv.lock optional bump #1383

Open
Open
@Lee-W

Description

@Lee-W

Description

uv.lock might not exists when the project is just initialized

Steps to reproduce

git init
uv init
cz init
sed  -i -e 's/pep621/uv/g' pyproject.toml pyproject.toml
git add .
cz commit
cz bump

Current behavior

FileNotFoundError: [Errno 2] No such file or directory: 'uv.lock'

Desired behavior

It should skip if uv.lock is not there yet.

Screenshots

No response

Environment

Commitizen Version: 4.5.0
Python Version: 3.12.7 (main, Oct 16 2024, 07:12:08) [Clang 18.1.8 ]
Operating System: Darwin

Activity

added theissue type on Apr 6, 2025
Yusin0903

Yusin0903 commented on Apr 6, 2025

@Yusin0903
Contributor

Hi @Lee-W, I used uv to create a virtual environment while working on another issue. I think I can give this one a try as well.

Lee-W

Lee-W commented on Apr 7, 2025

@Lee-W
MemberAuthor

That would be awesome 🙂

Yusin0903

Yusin0903 commented on Apr 8, 2025

@Yusin0903
Contributor

Hi @Lee-W,
I tried to reproduce the issue but everything works fine.
I was able to run cz bump successfully, as shown in the screenshot below.

Image

I tested it with both Python 3.10 and 3.12, and the Commitizen version in both cases was 4.5.0.
The only difference I noticed is that my system is Ubuntu 22.04.5.

Could youprovide more details about your environment and the issue you're encountering?

Lee-W

Lee-W commented on Apr 9, 2025

@Lee-W
MemberAuthor

Hi @Lee-W, I tried to reproduce the issue but everything works fine. I was able to run cz bump successfully, as shown in the screenshot below.

Image

I tested it with both Python 3.10 and 3.12, and the Commitizen version in both cases was 4.5.0. The only difference I noticed is that my system is Ubuntu 22.04.5.

Could youprovide more details about your environment and the issue you're encountering?

Ah, right, missing one crucial piece 🤦‍♂️ Just updated the commands above. so the idea is we still need to choose uv provider

Yusin0903

Yusin0903 commented on Apr 9, 2025

@Yusin0903
Contributor

Thanks, I will try to reproduce the situation.

bearomorphism

bearomorphism commented on Jun 9, 2025

@bearomorphism
Contributor

Steps to reproduce:

➜  workspace mkdir tmp
➜  workspace cd tmp
➜  tmp git init
uv init
cz init
sed  -i -e 's/pep621/uv/g' pyproject.toml pyproject.toml
git add .
cz commit
cz bump
Initialized empty Git repository in /Users/bearomorphism/workspace/tmp/.git/
Initialized project `tmp`
Welcome to commitizen!

Answer the questions to configure your project.
For further configuration visit:

https://commitizen-tools.github.io/commitizen/config/

? Please choose a supported config file:  .cz.toml
? Please choose a cz (commit rule): (default: cz_conventional_commits) cz_conventional_commits
? Choose the source of the version: uv: Get and Get and set version from pyproject.toml and uv.lock
No Existing Tag. Set tag to v0.0.1
? Choose version scheme:  pep440
? Please enter the correct version format: (default: "$version")
? Create changelog automatically on bump Yes
? Keep major version zero (0.x) during breaking changes Yes
? What types of pre-commit hook you want to install? (Leave blank if you don't want to install) done

You can bump the version running:

        cz bump

Configuration complete 🚀
? Select the type of change you are committing fix: A bug fix. Correlates with PATCH in SemVer
? What is the scope of this change? (class or file name): (press [enter] to skip)
 a
? Write a short and imperative summary of the code changes: (lower case and no period)
 a
? Provide additional contextual information about the code changes: (press [enter] to skip)
 a
? Is this a BREAKING CHANGE? Correlates with MAJOR in SemVer No
? Footer. Information about Breaking Changes and reference issues that this commit closes: (press [enter] to skip)
 

fix(a): a

a


[main (root-commit) 6329733] fix(a): a
 6 files changed, 28 insertions(+)
 create mode 100644 .cz.toml
 create mode 100644 .python-version
 create mode 100644 README.md
 create mode 100644 main.py
 create mode 100644 pyproject.toml
 create mode 100644 pyproject.toml-e

Commit successful!
No tag matching configuration could not be found.
Possible causes:
- version in configuration is not the current version
- tag_format or legacy_tag_formats is missing, check them using 'git tag --list'

? Is this the first tag created? Yes
bump: version 0.1.0 → 0.1.1
tag to create: 0.1.1
increment detected: PATCH

Traceback (most recent call last):
  File "/Users/bearomorphism/.local/bin/cz", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/bearomorphism/.local/share/uv/tools/commitizen/lib/python3.13/site-packages/commitizen/cli.py", line 660, in main
    args.func(conf, arguments)()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/bearomorphism/.local/share/uv/tools/commitizen/lib/python3.13/site-packages/commitizen/commands/bump.py", line 355, in __call__
    provider.set_version(str(new_version))
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/Users/bearomorphism/.local/share/uv/tools/commitizen/lib/python3.13/site-packages/commitizen/providers/uv_provider.py", line 28, in set_version
    self.set_lock_version(version)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/bearomorphism/.local/share/uv/tools/commitizen/lib/python3.13/site-packages/commitizen/providers/uv_provider.py", line 34, in set_lock_version
    document = tomlkit.parse(self.lock_file.read_text())
                             ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/bearomorphism/.local/share/uv/python/cpython-3.13.3-macos-aarch64-none/lib/python3.13/pathlib/_local.py", line 546, in read_text
    return PathBase.read_text(self, encoding, errors, newline)
           ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bearomorphism/.local/share/uv/python/cpython-3.13.3-macos-aarch64-none/lib/python3.13/pathlib/_abc.py", line 632, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors, newline=newline) as f:
         ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bearomorphism/.local/share/uv/python/cpython-3.13.3-macos-aarch64-none/lib/python3.13/pathlib/_local.py", line 537, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'uv.lock'
Lee-W

Lee-W commented on Jun 10, 2025

@Lee-W
MemberAuthor

hmmm... I thought we have it long ago. yep, we'll definitely need it @Yusin0903 would like to know whether you're still working on it. Thanks!

Yusin0903

Yusin0903 commented on Jun 10, 2025

@Yusin0903
Contributor

@Lee-W @bearomorphism
Sorry, I’ve been a bit busy lately. If this issue is urgent, feel free to take it over. I’ll focus on other issues later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @Lee-W@bearomorphism@Yusin0903

      Issue actions

        Make uv.lock optional bump · Issue #1383 · commitizen-tools/commitizen