Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fallback for poetry.update and poetry.update_to_latest #51

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ We follow [Semantic Versions](https://semver.org/).
## unreleased

- Improve `pre-commit.run-hooks` command with `params`
- Add fallback for `poetry.update` and `poetry.update_to_latest`

## 0.9.1

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,16 @@ Update dependencies with respect to
[version constraints](https://python-poetry.org/docs/dependency-specification/)
using [poetry up plugin](https://github.com/MousaZeidBaker/poetry-plugin-up).

Fallbacks to `poetry update` in case of an error.

#### poetry.update-to-latest

Update dependencies to latest versions using
[poetry up plugin](https://github.com/MousaZeidBaker/poetry-plugin-up).

By default fallbacks to [`update`](#poetryupdate) task in case of an error.
Use `--no-fallback` to stop on error.

### pip

#### pip.install-dependencies
Expand Down
25 changes: 23 additions & 2 deletions saritasa_invocations/poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,49 @@ def update(

https://python-poetry.org/docs/dependency-specification/

Fallbacks to `poetry update` in case of an error.

Requires:
https://github.com/MousaZeidBaker/poetry-plugin-up

"""
printing.print_success("Update dependencies")
context.run(f"poetry up {params} {_parse_groups(groups)}")
try:
context.run(f"poetry up {params} {_parse_groups(groups)}")
except invoke.UnexpectedExit:
printing.print_warn(
"Can't update with respect to version constraints using poetry up,"
" trying with poetry update",
)
context.run(f"poetry update {_parse_groups(groups)}")


@invoke.task
def update_to_latest(
context: invoke.Context,
groups: str = "",
params: str = "",
fallback: bool = True,
):
"""Update dependencies to latest versions using poetry up plugin.

By default fallbacks to `update` task in case of an error.

Requires:
https://github.com/MousaZeidBaker/poetry-plugin-up

"""
printing.print_success("Update dependencies to latest versions")
context.run(f"poetry up --latest {params} {_parse_groups(groups)}")
try:
context.run(f"poetry up --latest {params} {_parse_groups(groups)}")
except invoke.UnexpectedExit as error:
if not fallback:
raise error
printing.print_warn(
"Can't update to latest, try to update with respect to version"
" constraints.",
)
update(context, groups=groups, params=params)
TheSuperiorStanislav marked this conversation as resolved.
Show resolved Hide resolved


def _parse_groups(groups: str) -> str:
Expand Down