File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 99def read_config (config_file_name : Optional [str ]) -> Config :
1010 DEFAULT_FILENAME = "./pyproject.toml"
1111 if config_file_name is not None :
12- return Config .parse (toml .load (config_file_name )["coverage-threshold" ])
12+ if not os .path .isfile (config_file_name ):
13+ raise FileNotFoundError (f"Config file { config_file_name } not found" )
1314 else :
14- if os .path .isfile (DEFAULT_FILENAME ):
15- return Config .parse (
16- toml .load (DEFAULT_FILENAME ).get ("coverage-threshold" , {})
17- )
18- else :
19- return Config ()
15+ config_file_name = DEFAULT_FILENAME
16+ if os .path .isfile (config_file_name ):
17+ try :
18+ # PEP 518 compliant version
19+ return Config .parse (toml .load (config_file_name )["tool" ]["coverage-threshold" ])
20+ except KeyError :
21+ # Legacy version
22+ return Config .parse (toml .load (config_file_name ).get ("coverage-threshold" , {}))
23+ else :
24+ return Config ()
You can’t perform that action at this time.
0 commit comments