File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 66import yaml
77from pydantic import RootModel
88
9+ from cmdcomp .exception import ConfigFileExtensionError
910from cmdcomp .v1 .config import V1Config
1011from cmdcomp .v2 .config import V2Config
1112
@@ -17,8 +18,8 @@ class Config(RootModel):
1718
1819
1920def load (file : BinaryIO ) -> Config :
20- _ , extention = os .path .splitext (file .name )
21- match extention :
21+ _ , extension = os .path .splitext (file .name )
22+ match extension :
2223 case ".json" :
2324 data = json .load (file )
2425
@@ -29,6 +30,6 @@ def load(file: BinaryIO) -> Config:
2930 data = tomllib .load (file )
3031
3132 case _:
32- raise Exception ( f"Unsupported config file type ` { extention } `." )
33+ raise ConfigFileExtensionError ( extension )
3334
3435 return Config .model_validate (data )
Original file line number Diff line number Diff line change 11from typing import Never
22
33
4+ class ConfigFileExtensionError (Exception ):
5+ def __init__ (self , extension : str ) -> None :
6+ self ._extension = extension
7+
8+ def __str__ (self ) -> str :
9+ return f'config file extension "{ self ._extension } " is not supported.'
10+
11+
412class NeverReach (Exception ):
513 def __init__ (self , value : Never ) -> None :
614 self ._value = value
You can’t perform that action at this time.
0 commit comments