Skip to content

Commit 8d84557

Browse files
committed
Use a type alias for str | Path.
The motivation is that the `|` operator for types is a 3.10+ feature and `Optional[Union[str, Path]]` is a bit awkward.
1 parent 3d2364e commit 8d84557

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/psij/job_spec.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import sys
44
from pathlib import Path
5-
from typing import Any, Dict, List, Optional
5+
from typing import Any, Dict, List, Optional, Union
66

77
from typeguard import check_argument_types
88

@@ -11,16 +11,17 @@
1111
from psij.utils import path_object_to_full_path as o2p
1212

1313

14+
StrOrPath = Union[str, Path]
1415
class JobSpec(object):
1516
"""A class to hold information about the characteristics of a:class:`~psij.Job`."""
1617

1718
def __init__(self, name: Optional[str] = None, executable: Optional[str] = None,
18-
arguments: Optional[List[str]] = None, directory: Optional[str | Path] = None,
19+
arguments: Optional[List[str]] = None, directory: Optional[StrOrPath] = None,
1920
inherit_environment: bool = True, environment: Optional[Dict[str, str]] = None,
20-
stdin_path: Optional[str | Path] = None, stdout_path: Optional[str | Path] = None,
21-
stderr_path: Optional[str | Path] = None, resources: Optional[ResourceSpec] = None,
22-
attributes: Optional[JobAttributes] = None, pre_launch: Optional[str | Path] = None,
23-
post_launch: Optional[str | Path] = None, launcher: Optional[str] = None):
21+
stdin_path: Optional[StrOrPath] = None, stdout_path: Optional[StrOrPath] = None,
22+
stderr_path: Optional[StrOrPath] = None, resources: Optional[ResourceSpec] = None,
23+
attributes: Optional[JobAttributes] = None, pre_launch: Optional[StrOrPath] = None,
24+
post_launch: Optional[StrOrPath] = None, launcher: Optional[str] = None):
2425
"""
2526
Constructs a `JobSpec` object while allowing its properties to be initialized.
2627

0 commit comments

Comments
 (0)