66"""
77import logging
88import os
9- from typing import Dict
9+ from pathlib import PosixPath
10+ from typing import Any , Dict , List , Optional , Union
1011
1112from . import exc
1213
1314logger = logging .getLogger (__name__ )
1415
1516
16- def validate_schema (session_config ) :
17+ def validate_schema (session_config : Any ) -> bool :
1718 """
1819 Return True if config schema is correct.
1920
@@ -45,7 +46,9 @@ def validate_schema(session_config):
4546 return True
4647
4748
48- def is_config_file (filename , extensions = [".yml" , ".yaml" , ".json" ]):
49+ def is_config_file (
50+ filename : str , extensions : List [str ] = [".yml" , ".yaml" , ".json" ]
51+ ) -> bool :
4952 """
5053 Return True if file has a valid config file type.
5154
@@ -65,8 +68,9 @@ def is_config_file(filename, extensions=[".yml", ".yaml", ".json"]):
6568
6669
6770def in_dir (
68- config_dir = os .path .expanduser ("~/.tmuxp" ), extensions = [".yml" , ".yaml" , ".json" ]
69- ):
71+ config_dir : PosixPath = os .path .expanduser ("~/.tmuxp" ),
72+ extensions : List [str ] = [".yml" , ".yaml" , ".json" ],
73+ ) -> List [str ]:
7074 """
7175 Return a list of configs in ``config_dir``.
7276
@@ -90,7 +94,7 @@ def in_dir(
9094 return configs
9195
9296
93- def in_cwd ():
97+ def in_cwd () -> List [ str ] :
9498 """
9599 Return list of configs in current working directory.
96100
@@ -115,7 +119,7 @@ def in_cwd():
115119 return configs
116120
117121
118- def expandshell (_path ) :
122+ def expandshell (_path : str ) -> str :
119123 """
120124 Return expanded path based on user's ``$HOME`` and ``env``.
121125
@@ -134,7 +138,7 @@ def expandshell(_path):
134138 return os .path .expandvars (os .path .expanduser (_path ))
135139
136140
137- def inline (session_config ) :
141+ def inline (session_config : Dict [ str , Any ]) -> Any :
138142 """
139143 Return config in inline form, opposite of :meth:`config.expand`.
140144
@@ -210,7 +214,11 @@ def expand_cmd(p: Dict) -> Dict:
210214 return p
211215
212216
213- def expand (session_config , cwd = None , parent = None ):
217+ def expand (
218+ session_config : Any ,
219+ cwd : Optional [Union [str , PosixPath ]] = None ,
220+ parent : Optional [Any ] = None ,
221+ ) -> Dict [str , Any ]:
214222 """Return config with shorthand and inline properties expanded.
215223
216224 This is necessary to keep the code in the :class:`WorkspaceBuilder` clean
@@ -330,7 +338,7 @@ def expand(session_config, cwd=None, parent=None):
330338 return session_config
331339
332340
333- def trickle (session_config ) :
341+ def trickle (session_config : Dict [ str , Any ]) -> Dict [ str , Any ] :
334342 """Return a dict with "trickled down" / inherited config values.
335343
336344 This will only work if config has been expanded to full form with
@@ -414,7 +422,7 @@ def trickle(session_config):
414422 return session_config
415423
416424
417- def import_tmuxinator (session_config ) :
425+ def import_tmuxinator (session_config : Dict [ str , Any ]) -> Dict [ str , Any ] :
418426 """Return tmuxp config from a `tmuxinator`_ yaml config.
419427
420428 .. _tmuxinator: https://github.com/aziz/tmuxinator
@@ -508,7 +516,7 @@ def import_tmuxinator(session_config):
508516 return tmuxp_config
509517
510518
511- def import_teamocil (session_config ) :
519+ def import_teamocil (session_config : Dict [ str , Any ]) -> Dict [ str , Any ] :
512520 """Return tmuxp config from a `teamocil`_ yaml config.
513521
514522 .. _teamocil: https://github.com/remiprev/teamocil
0 commit comments