2626 import subprocess
2727
2828
29- def get_shell_types ():
29+ def get_shell_types () -> list [ str ] :
3030 """Returns the available shell types: bash, tcsh etc.
3131
3232 Returns:
@@ -36,7 +36,7 @@ def get_shell_types():
3636 return list (plugin_manager .get_plugins ('shell' ))
3737
3838
39- def get_shell_class (shell = None ):
39+ def get_shell_class (shell = None ) -> type [ Shell ] :
4040 """Get the plugin class associated with the given or current shell.
4141
4242 Returns:
@@ -49,7 +49,7 @@ def get_shell_class(shell=None):
4949 shell = system .shell
5050
5151 from rez .plugin_managers import plugin_manager
52- return plugin_manager .get_plugin_class ("shell" , shell )
52+ return plugin_manager .get_plugin_class ("shell" , shell , type = Shell )
5353
5454
5555def create_shell (shell : str | None = None , ** kwargs ) -> Shell :
@@ -74,29 +74,29 @@ class Shell(ActionInterpreter):
7474 schema_dict = {"prompt" : str }
7575
7676 @classmethod
77- def name (cls ):
77+ def name (cls ) -> str :
7878 """Plugin name.
7979 """
8080 raise NotImplementedError
8181
8282 @classmethod
83- def executable_name (cls ):
83+ def executable_name (cls ) -> str :
8484 """Name of executable to create shell instance.
8585 """
8686 return cls .name ()
8787
8888 @classmethod
89- def executable_filepath (cls ):
89+ def executable_filepath (cls ) -> str :
9090 """Get full filepath to executable, or raise if not found.
9191 """
9292 return cls .find_executable (cls .executable_name ())
9393
9494 @property
95- def executable (self ):
95+ def executable (self ) -> str :
9696 return self .__class__ .executable_filepath ()
9797
9898 @classmethod
99- def is_available (cls ):
99+ def is_available (cls ) -> bool :
100100 """Determine if the shell is available to instantiate.
101101
102102 Returns:
@@ -108,7 +108,7 @@ def is_available(cls):
108108 return False
109109
110110 @classmethod
111- def file_extension (cls ):
111+ def file_extension (cls ) -> str :
112112 """Get the file extension associated with the shell.
113113
114114 Returns:
@@ -139,7 +139,7 @@ def __init__(self):
139139 def _addline (self , line ):
140140 self ._lines .append (line )
141141
142- def get_output (self , style = OutputStyle .file ):
142+ def get_output (self , style = OutputStyle .file ) -> str :
143143 if style == OutputStyle .file :
144144 script = '\n ' .join (self ._lines ) + '\n '
145145 else : # eval style
@@ -240,7 +240,7 @@ def spawn_shell(self, context_file, tmpdir, rcfile=None, norc=False,
240240 raise NotImplementedError
241241
242242 @classmethod
243- def convert_tokens (cls , value ):
243+ def convert_tokens (cls , value ) -> str :
244244 """
245245 Converts any token like ${VAR} and $VAR to shell specific form.
246246 Uses the ENV_VAR_REGEX to correctly parse tokens.
@@ -257,7 +257,7 @@ def convert_tokens(cls, value):
257257 )
258258
259259 @classmethod
260- def get_key_token (cls , key ):
260+ def get_key_token (cls , key ) -> str :
261261 """
262262 Encodes the environment variable into the shell specific form.
263263 Shells might implement multiple forms, but the most common/safest
@@ -272,7 +272,7 @@ def get_key_token(cls, key):
272272 return cls .get_all_key_tokens (key )[0 ]
273273
274274 @classmethod
275- def get_all_key_tokens (cls , key ):
275+ def get_all_key_tokens (cls , key ) -> list [ str ] :
276276 """
277277 Encodes the environment variable into the shell specific forms.
278278 Shells might implement multiple forms, but the most common/safest
@@ -287,15 +287,15 @@ def get_all_key_tokens(cls, key):
287287 raise NotImplementedError
288288
289289 @classmethod
290- def line_terminator (cls ):
290+ def line_terminator (cls ) -> str :
291291 """
292292 Returns:
293293 str: default line terminator
294294 """
295295 raise NotImplementedError
296296
297297 @classmethod
298- def join (cls , command ):
298+ def join (cls , command ) -> str :
299299 """
300300 Note: Default to unix sh/bash- friendly behaviour.
301301
@@ -328,10 +328,10 @@ class UnixShell(Shell):
328328 r"""
329329 A base class for common \*nix shells, such as bash and tcsh.
330330 """
331- rcfile_arg = None
332- norc_arg = None
333- histfile = None
334- histvar = None
331+ rcfile_arg : str = None
332+ norc_arg : str = None
333+ histfile : str = None
334+ histvar : str = None
335335 command_arg = '-c'
336336 stdin_arg = '-s'
337337 last_command_status = '$?'
@@ -518,21 +518,21 @@ def _create_ex():
518518 % (cmd_str , str (e )))
519519 return p
520520
521- def resetenv (self , key , value , friends = None ):
521+ def resetenv (self , key , value , friends = None ) -> None :
522522 self ._addline (self .setenv (key , value ))
523523
524- def info (self , value ):
524+ def info (self , value ) -> None :
525525 for line in value .split ('\n ' ):
526526 line = self .escape_string (line )
527527 self ._addline ('echo %s' % line )
528528
529- def error (self , value ):
529+ def error (self , value ) -> None :
530530 for line in value .split ('\n ' ):
531531 line = self .escape_string (line )
532532 self ._addline ('echo %s 1>&2' % line )
533533
534534 # escaping is allowed in args, but not in program string
535- def command (self , value ):
535+ def command (self , value ) -> None :
536536 if is_non_string_iterable (value ):
537537 it = iter (value )
538538 cmd = EscapedString .disallow (next (it ))
@@ -542,18 +542,18 @@ def command(self, value):
542542 value = EscapedString .disallow (value )
543543 self ._addline (value )
544544
545- def comment (self , value ):
545+ def comment (self , value ) -> None :
546546 value = EscapedString .demote (value )
547547 for line in value .split ('\n ' ):
548548 self ._addline ('# %s' % line )
549549
550- def shebang (self ):
550+ def shebang (self ) -> None :
551551 self ._addline ("#!%s" % self .executable )
552552
553553 @classmethod
554554 def get_all_key_tokens (cls , key ):
555555 return ["${%s}" % key , "$%s" % key ]
556556
557557 @classmethod
558- def line_terminator (cls ):
558+ def line_terminator (cls ) -> str :
559559 return "\n "
0 commit comments