Executable: allow also pathlib.Path in constructor

This commit is contained in:
Massimiliano Culpo 2025-01-10 11:55:18 +01:00
parent dc96b3cbc1
commit 8f1be225dd
No known key found for this signature in database
GPG Key ID: 3E52BB992233066C

View File

@ -20,9 +20,9 @@
class Executable:
"""Class representing a program that can be run on the command line."""
def __init__(self, name: str) -> None:
def __init__(self, name: Union[str, Path]) -> None:
file_path = str(Path(name))
if sys.platform != "win32" and name.startswith("."):
if sys.platform != "win32" and isinstance(name, str) and name.startswith("."):
# pathlib strips the ./ from relative paths so it must be added back
file_path = os.path.join(".", file_path)