Skip to content

Poetry

install(context)

Install dependencies via poetry.

Source code in saritasa_invocations/poetry.py
 6
 7
 8
 9
10
@invoke.task
def install(context: invoke.Context) -> None:
    """Install dependencies via poetry."""
    printing.print_success("Install dependencies with poetry")
    context.run("poetry sync")

update(context, groups='', params='')

Update dependencies with respect to version constraints using poetry up.

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

Fallbacks to poetry update in case of an error.

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

Source code in saritasa_invocations/poetry.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@invoke.task
def update(
    context: invoke.Context,
    groups: str = "",
    params: str = "",
) -> None:
    """Update dependencies with respect to version constraints using poetry up.

    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")
    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)}")

update_to_latest(context, groups='', params='', fallback=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

Source code in saritasa_invocations/poetry.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
@invoke.task
def update_to_latest(
    context: invoke.Context,
    groups: str = "",
    params: str = "",
    fallback: bool = True,
) -> None:
    """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")
    try:
        context.run(f"poetry up --latest {params} {_parse_groups(groups)}")
    except invoke.UnexpectedExit:
        if not fallback:
            raise
        printing.print_warn(
            "Can't update to latest, try to update with respect to version"
            " constraints.",
        )
        update(context, groups=groups, params=params)