1+ """Configure pytask."""
12import configparser
23import itertools
34import os
3233 "build/*" ,
3334 "dist/*" ,
3435]
36+ """List[str]: List of expressions to ignore folders."""
3537
3638
3739@hookimpl
3840def pytask_configure (pm , config_from_cli ):
41+ """Configure pytask."""
3942 config = {"pm" : pm , "terminal_width" : _get_terminal_width ()}
4043
4144 # Either the path to the configuration is passed via the CLI or it needs to be
@@ -88,17 +91,19 @@ def pytask_configure(pm, config_from_cli):
8891
8992@hookimpl
9093def pytask_parse_config (config , config_from_cli , config_from_file ):
94+ """Parse the configuration."""
9195 config_from_file ["ignore" ] = parse_value_or_multiline_option (
9296 config_from_file .get ("ignore" )
9397 )
9498
9599 config ["ignore" ] = (
96- get_first_non_none_value (
97- config_from_cli ,
98- config_from_file ,
99- key = "ignore" ,
100- default = [],
101- callback = to_list ,
100+ to_list (
101+ get_first_non_none_value (
102+ config_from_cli ,
103+ config_from_file ,
104+ key = "ignore" ,
105+ default = [],
106+ )
102107 )
103108 + IGNORED_FOLDERS
104109 )
@@ -117,7 +122,7 @@ def pytask_parse_config(config, config_from_cli, config_from_file):
117122
118123@hookimpl
119124def pytask_post_parse (config ):
120- # Sort markers alphabetically.
125+ """ Sort markers alphabetically."""
121126 config ["markers" ] = {k : config ["markers" ][k ] for k in sorted (config ["markers" ])}
122127
123128
@@ -144,9 +149,11 @@ def _find_project_root_and_ini(paths: List[Path]):
144149 path = parent .joinpath (config_name )
145150
146151 if path .exists ():
147- config = configparser .ConfigParser ()
148- config .read (path )
149- if "pytask" in config .sections ():
152+ try :
153+ _read_config (path )
154+ except Exception :
155+ pass
156+ else :
150157 config_path = path
151158 break
152159
@@ -159,6 +166,7 @@ def _find_project_root_and_ini(paths: List[Path]):
159166
160167
161168def _read_config (path ):
169+ """Read the configuration from a file with a [pytask] section."""
162170 config = configparser .ConfigParser ()
163171 config .read (path )
164172 return dict (config ["pytask" ])
0 commit comments