Skip to content

dependence.update

update

update(
    paths: collections.abc.Iterable[str | pathlib.Path],
    *,
    ignore: collections.abc.Iterable[str] = (),
    all_extra_name: str = "",
    include_pointers: tuple[str, ...] = (),
    exclude_pointers: tuple[str, ...] = ()
) -> None

Update requirement versions in the specified files.

Parameters:

  • paths (collections.abc.Iterable[str | pathlib.Path]) –

    One or more local paths to a pyproject.toml, setup.cfg, and/or requirements.txt files

  • ignore (collections.abc.Iterable[str], default: () ) –

    One or more project/package names to ignore (leave as-is) when updating dependency requirement specifiers.

  • all_extra_name (str, default: '' ) –

    If provided, an extra which consolidates the requirements for all other extras will be added/updated to pyproject.toml or setup.cfg (this argument is ignored for requirements.txt files)

  • include_pointers (tuple[str, ...], default: () ) –

    A tuple of JSON pointers indicating elements to include (defaults to all elements). This applies only to TOML files (including pyproject.toml), and is ignored for all other file types.

  • exclude_pointers (tuple[str, ...], default: () ) –

    A tuple of JSON pointers indicating elements to exclude (defaults to no exclusions). This applies only to TOML files (including pyproject.toml), and is ignored for all other file types.

Source code in src/dependence/update.py
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
def update(
    paths: Iterable[str | Path],
    *,
    ignore: Iterable[str] = (),
    all_extra_name: str = "",
    include_pointers: tuple[str, ...] = (),
    exclude_pointers: tuple[str, ...] = (),
) -> None:
    """
    Update requirement versions in the specified files.

    Parameters:
        paths: One or more local paths to a pyproject.toml,
            setup.cfg, and/or requirements.txt files
        ignore: One or more project/package names to ignore (leave
            as-is) when updating dependency requirement specifiers.
        all_extra_name: If provided, an extra which consolidates
            the requirements for all other extras will be added/updated to
            pyproject.toml or setup.cfg (this argument is ignored for
            requirements.txt files)
        include_pointers: A tuple of JSON pointers indicating elements to
            include (defaults to all elements). This applies only to TOML
            files (including pyproject.toml), and is ignored for all other
            file types.
        exclude_pointers: A tuple of JSON pointers indicating elements to
            exclude (defaults to no exclusions). This applies only to TOML
            files (including pyproject.toml), and is ignored for all other
            file types.
    """
    if isinstance(paths, (str, Path)):
        paths = (paths,)

    def update_(path: str | Path) -> None:
        _update(
            path,
            ignore=ignore,
            all_extra_name=all_extra_name,
            include_pointers=include_pointers,
            exclude_pointers=exclude_pointers,
        )

    deque(map(update_, paths), maxlen=0)