Skip to content

Commit

Permalink
cli: update parsing inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Nov 19, 2024
1 parent 5a31a07 commit 173dbf6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/lightning_utilities/cli/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import glob
import os.path
from pprint import pprint
from typing import Sequence
from typing import Sequence, Union

REQUIREMENT_ROOT = "requirements.txt"
REQUIREMENT_FILES_ALL: list = glob.glob(os.path.join("requirements", "*.txt"))
Expand All @@ -14,8 +14,12 @@
REQUIREMENT_FILES_ALL += [REQUIREMENT_ROOT]


def prune_pkgs_in_requirements(packages: Sequence[str], req_files: Sequence[str] = REQUIREMENT_FILES_ALL) -> None:
def prune_pkgs_in_requirements(
packages: Union[str, Sequence[str]], req_files: Union[str, Sequence[str]] = REQUIREMENT_FILES_ALL
) -> None:
"""Remove some packages from given requirement files."""
if isinstance(packages, str):
packages = [packages]
if isinstance(req_files, str):
req_files = [req_files]
for req in req_files:
Expand Down Expand Up @@ -44,7 +48,9 @@ def _replace_min(fname: str) -> None:
fw.write(req)


def replace_oldest_ver(req_files: Sequence[str] = REQUIREMENT_FILES_ALL) -> None:
def replace_oldest_ver(req_files: Union[str, Sequence[str]] = REQUIREMENT_FILES_ALL) -> None:
"""Replace the min package version by fixed one."""
if isinstance(req_files, str):
req_files = [req_files]
for fname in req_files:
_replace_min(fname)

0 comments on commit 173dbf6

Please sign in to comment.