diff --git a/flupdt/cli.py b/flupdt/cli.py index dbf9f92..80c3362 100644 --- a/flupdt/cli.py +++ b/flupdt/cli.py @@ -4,11 +4,7 @@ import argparse def parse_inputs(): parser = argparse.ArgumentParser() - parser.add_argument( - "flake_path", metavar="flake-path", help="path to flake to evaluate" - ) - parser.add_argument( - "--keep-hydra", action="store_true", help="allow evaluating Hydra jobs" - ) + parser.add_argument("flake_path", metavar="flake-path", help="path to flake to evaluate") + parser.add_argument("--keep-hydra", action="store_true", help="allow evaluating Hydra jobs") args = parser.parse_args() return args diff --git a/flupdt/flake_show.py b/flupdt/flake_show.py index b9113ce..e77dd97 100644 --- a/flupdt/flake_show.py +++ b/flupdt/flake_show.py @@ -33,9 +33,7 @@ def traverse_json(json_dict: dict) -> list[str]: def get_derivations_from_check(nix_path: str, path_to_flake: str) -> list[str]: - flake_check = bash_wrapper( - f"{nix_path} flake check --verbose --keep-going", path=path_to_flake - ) + flake_check = bash_wrapper(f"{nix_path} flake check --verbose --keep-going", path=path_to_flake) if flake_check[2] != 0: logging.warn( "nix flake check returned non-zero exit code, collecting all available outputs" @@ -57,9 +55,7 @@ def get_derivations(path_to_flake: str) -> list[str]: nix_path = shutil.which("nix") derivations = [] if nix_path is None: - raise RuntimeError( - "nix is not available in the PATH, please verify that it is installed" - ) + raise RuntimeError("nix is not available in the PATH, please verify that it is installed") flake_show = bash_wrapper(f"{nix_path} flake show --json", path=path_to_flake) if flake_show[2] != 0: logging.error("flake show returned non-zero exit code") diff --git a/flupdt/main.py b/flupdt/main.py index ecd6217..95d8bb2 100644 --- a/flupdt/main.py +++ b/flupdt/main.py @@ -10,19 +10,21 @@ import rad_development_python as rd def main(): rd.configure_logger("INFO") args = parse_inputs() - print("hi") flake_path = args.flake_path - derivations = get_derivations(flake_path) - if ( - not args.keep_hydra - and len(list(filter(lambda s: s.startswith("hydraJobs"), derivations))) > 0 - ): - logging.info("--keep-hydra flag is not specified, removing Hydra jobs") - derivations = filter(lambda s: not s.startswith("hydraJobs"), derivations) + derivations, hydraJobs = rd.partition( + lambda s: s.startswith("hydraJobs"), get_derivations(flake_path) + ) logging.info(f"derivations: {list(derivations)}") for d in derivations: evaluate_output(flake_path, d) + if not args.keep_hydra: + logging.info("--keep-hydra flag is not specified, removing Hydra jobs") + else: + logging.info(f"hydraJobs: {list(hydraJobs)}") + for d in hydraJobs: + evaluate_output(flake_path, d) + if __name__ == "__main__": main() diff --git a/pyproject.toml b/pyproject.toml index 9d93ebd..ee22431 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,39 @@ flake-update-diff = "flupdt.main:main" [tool.poetry.group.dev.dependencies] ruff = "0.5.5" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" + +[tool.ruff] + +line-length = 100 +indent-width = 4 + +target-version = "py39" + +[tool.ruff.lint] +select = ["ALL"] +ignore = [ + "ANN101", # (perm) this rule is deprecated + "ANN102", # (perm) this rule is deprecated + "G004", # (perm) this is a performance nit +] + +[tool.ruff.lint.per-file-ignores] + +"tests/**" = [ + "S101", # (perm) pytest needs asserts +] + +fixable = ["ALL"] + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.lint.pycodestyle] +max-line-length = 120 + +[tool.ruff.lint.pylint] +max-args = 9