3131TODO
3232"""
3333
34+ from __future__ import annotations
35+
3436import os
3537from pathlib import Path
36- from typing import Dict , List , Optional , Sequence , Union
3738
3839from .paths import find_exe
3940from .service import Service
4041
4142
4243class Environment :
43- def __init__ (self , base : Union [ Path , str ] , use_system_path : bool = False ):
44+ def __init__ (self , base : Path | str , use_system_path : bool = False ):
4445 self .base = Path (base ).absolute ()
4546 self .use_system_path = use_system_path
4647
@@ -71,8 +72,8 @@ def python(self) -> Service:
7172
7273 def groovy (
7374 self ,
74- class_path : Optional [ Sequence [ str ]] = None ,
75- jvm_args : Optional [ Sequence [ str ]] = None ,
75+ class_path : list [ str ] | None = None ,
76+ jvm_args : list [ str ] | None = None ,
7677 ) -> Service :
7778 """
7879 Create a Groovy script service. Groovy (https://groovy-lang.org/)
@@ -101,11 +102,11 @@ def groovy(
101102 def java (
102103 self ,
103104 main_class : str ,
104- class_path : Optional [ Sequence [ str ]] = None ,
105- jvm_args : Optional [ Sequence [ str ]] = None ,
105+ class_path : list [ str ] | None = None ,
106+ jvm_args : list [ str ] | None = None ,
106107 ) -> Service :
107108 # Collect classpath elements into a set, to avoid duplicate entries.
108- cp : Dict [str ] = {} # NB: Use dict instead of set to maintain insertion order.
109+ cp : dict [str ] = {} # NB: Use dict instead of set to maintain insertion order.
109110
110111 # TODO: Ensure that the classpath includes Appose and its dependencies.
111112
@@ -134,7 +135,7 @@ def java(
134135 ]
135136 return self .service (java_exes , * args )
136137
137- def service (self , exes : Sequence [str ], * args ) -> Service :
138+ def service (self , exes : list [str ], * args ) -> Service :
138139 """
139140 Create a service with the given command line arguments.
140141
@@ -156,7 +157,7 @@ def service(self, exes: Sequence[str], *args) -> Service:
156157 if not exes :
157158 raise ValueError ("No executable given" )
158159
159- dirs : List [str ] = (
160+ dirs : list [str ] = (
160161 os .environ ["PATH" ].split (os .pathsep )
161162 if self .use_system_path
162163 else [self .base ]
@@ -166,6 +167,6 @@ def service(self, exes: Sequence[str], *args) -> Service:
166167 if exe_file is None :
167168 raise ValueError (f"No executables found amongst candidates: { exes } " )
168169
169- all_args : List [str ] = [str (exe_file )]
170+ all_args : list [str ] = [str (exe_file )]
170171 all_args .extend (args )
171172 return Service (self .base , all_args )
0 commit comments