MCPcopy Index your code
hub / github.com/plotly/plotly.py / bump_version_pyproject_toml

Function bump_version_pyproject_toml

commands.py:283–316  ·  view source on GitHub ↗

Bump the version in pyproject.toml to new_version Returns True on success, False on failure

(new_version)

Source from the content-addressed store, hash-verified

281
282
283def bump_version_pyproject_toml(new_version):
284 """
285 Bump the version in pyproject.toml to new_version
286 Returns True on success, False on failure
287 """
288 pyproject_toml_path = "pyproject.toml"
289 pattern = r'(^\s*version\s*=\s*")([\w.]+)"(\s*$)'
290 with open(pyproject_toml_path, "r") as f:
291 content = f.read()
292 new_content, n_subs = re.subn(
293 pattern,
294 rf'\g<1>{new_version}"\g<3>',
295 content,
296 count=1, # replace only the first match
297 flags=re.MULTILINE,
298 )
299 if n_subs < 1:
300 print(
301 f"FAILED to update version in {pyproject_toml_path}.",
302 "Please update manually and then run `uv lock`.",
303 )
304 return False
305
306 with open(pyproject_toml_path, "w") as f:
307 f.write(new_content)
308
309 # Run `uv lock` to update the version number in the `uv.lock` file (do not update manually)
310 subprocess.run(["uv", "lock"], check=True)
311
312 print(
313 f"SUCCESS: Updated version in {pyproject_toml_path} to {new_version},",
314 "and updated uv lockfile",
315 )
316 return True
317
318
319def bump_version_package_json(new_version):

Callers 1

bump_versionFunction · 0.85

Calls 3

readMethod · 0.80
writeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected