From 663dadbcd925703ad656e462ab27e4695b28a161 Mon Sep 17 00:00:00 2001 From: kmario23 Date: Sun, 20 Oct 2024 19:17:30 +0000 Subject: [PATCH] comply with ruff linter --- pdebench/data_gen/src/utils.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pdebench/data_gen/src/utils.py b/pdebench/data_gen/src/utils.py index 8e284bc..2ad4fae 100644 --- a/pdebench/data_gen/src/utils.py +++ b/pdebench/data_gen/src/utils.py @@ -2,6 +2,7 @@ import glob import os +from pathlib import Path from pprint import pprint from omegaconf import DictConfig, OmegaConf @@ -11,14 +12,14 @@ def expand_path(path, unique=True): """ Resolve a path that may contain variables and user home directory references. """ - return os.path.expandvars(os.path.expanduser(path)) + return os.path.expandvars(Path(path).expanduser()) def matching_paths(glob_exp): """ return a list of paths matching a glob expression """ - path = os.path.expandvars(os.path.expanduser(glob_exp)) + path = os.path.expandvars(Path(glob_exp).expanduser()) return glob.glob(path) @@ -35,12 +36,13 @@ def resolve_path(path, idx=None, unique=True): matches = sorted(matches) if unique and len(matches) > 1: - raise ValueError(f"Too many matches for glob: {path}") - else: - try: - return matches[idx] - except IndexError: - raise FileNotFoundError(f"No matches for glob: {path}") + valerrmsg = f"Too many matches for glob: {path}" + raise ValueError(valerrmsg) + try: + return matches[idx] + except IndexError: + idxerrmsg = f"No matches for glob: {path}" + raise FileNotFoundError(idxerrmsg) def print_config(