Last active
April 23, 2025 13:50
-
-
Save yhoiseth/c80c1e44a7036307e424fce616eed25e to your computer and use it in GitHub Desktop.
Upgrade all dependencies to their latest version using uv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# https://gist.github.com/yhoiseth/c80c1e44a7036307e424fce616eed25e | |
from typing import Any | |
from re import match, Match | |
import toml | |
import subprocess | |
def main() -> None: | |
with open("pyproject.toml", "r") as file: | |
pyproject: dict[str, Any] = toml.load(file) | |
dependencies: list[str] = pyproject["project"]["dependencies"] | |
package_name_pattern = r"^[a-zA-Z0-9\-]+" | |
for dependency in dependencies: | |
package_match = match(package_name_pattern, dependency) | |
assert isinstance(package_match, Match) | |
package = package_match.group(0) | |
uv("remove", package) | |
uv("add", package) | |
def uv(command: str, package: str) -> None: | |
subprocess.run(["uv", command, package]) | |
if __name__ == "__main__": | |
main() |
After trying these and similar commands, I've returned to Renovate Bot to upgrade my packages. Bot does it in more configurable way, even if I run it locally
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great!!