question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`bump` is also changing dependency versions in `pyproject.toml`, when the versions are the same

See original GitHub issue

Description

When a dep is specified using the {} syntax, eg

smart-open = {version = ">=5.2.0,<6.1.0", extras = ["s3"]}

and the version of the dep matches the version of the project, then bump will change both versions.

Is it possible to specify a regex in the configuration - ie to ensure that the version string is at the start of line, not in the middle?

Ref https://commitizen-tools.github.io/commitizen/config/#pyprojecttoml-or-cztoml

Steps to reproduce

Create a project, where the project version is the same as a dependency version, and where the dependency uses poetry’s optional {} syntax

mkdir bug-report

cd bug-report

cat << EOF > pyproject.toml
[tool.poetry]
name = "foo"
version = "6.1.0"
description = "foo"
authors = ["First Last <firstLast@example.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
smart-open = {version = ">=5.2.0,<6.1.0", extras = ["s3"]}

[tool.commitizen]
name = "cz_conventional_commits"
version = "6.1.0"
version_files = ["pyproject.toml:version"]
tag_format = "v$version"
EOF

Init

git init
git add .
git commit -m 'first commit'

Check the current version of the project

❯ cz version --project
6.1.0

Make a change

mkdir src
touch src/__init__.py
git add .
git commit -m 'feat: a feature'

bump the project

❯ cz bump --yes
bump: version 6.1.0 → 6.2.0
tag to create: v6.2.0
increment detected: MINOR

Done!

See the version change in the dependency…

❯ cat pyproject.toml
[tool.poetry]
name = "foo"
version = "6.2.0"
description = "foo"
authors = ["Andrew Sheridan <asheridan25@massmutual.com>"]
readme = "README.md"
packages = [{ include = "massmutual", from = "src"}]

[tool.poetry.dependencies]
python = "^3.9"
smart-open = {version = ">=5.2.0,<6.2.0", extras = ["s3"]}

[tool.commitizen]
name = "cz_conventional_commits"
version = "6.2.0"
version_files = ["pyproject.toml:version"]
tag_format = "v$version"

This line should not have changed: smart-open = {version = ">=5.2.0,<6.2.0", extras = ["s3"]}

Current behavior

bump erroneously changes more than it should in the toml file

Desired behavior

bump only changes the right strings in the toml file

Screenshots

No response

Environment

cz version -> 2.23.0

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
woilecommented, Apr 7, 2022

Yes, updating the docs should be enough, would you mind sending a pr or describing here where would you update? Thanks

1reaction
Kurt-von-Lavencommented, May 4, 2022

I suppose it might also help to clarify in the documentation I linked to above that the pattern is a Python regular expression matched using re.finditer. That would also serve the purpose of clarifying that the file isn’t searched line by line. Or see #498 for a proposed alternative to the current matching behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dependency version syntax for Python Poetry - Stack Overflow
In pyproject.toml, you use the [tool.poetry.dependencies] and ... only a major version, then minor- and patch-level changes are allowed.
Read more >
Commands | Documentation | Poetry - Python dependency ...
This command shows the current version of the project or bumps the version of the project and writes the new version back to...
Read more >
Dependency Scanning - GitLab Docs
If your project does not use a gradlew file, then the analyzer automatically switches to one of the pre-installed Gradle versions, based on...
Read more >
7. Releasing and versioning - Python Packages
We call an increment a “bump”, and it consists of adding 1 to either the major, ... This command changes the version variable...
Read more >
Release Checklist - Nautobot Documentation
Where possible, we use tilde requirements to specify a minimal version with ... is used to resolve and install all dependencies listed in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found