22
33import os
44from pathlib import Path
5+ from typing import Any , Self
56
67from tomlkit import exceptions , parse , table
78
@@ -14,10 +15,10 @@ class TomlConfig(BaseConfig):
1415 def __init__ (self , * , data : bytes | str , path : Path | str ):
1516 super ().__init__ ()
1617 self .is_empty_config = False
17- self .path = path # type: ignore
18+ self .path : Path = path # type: ignore
1819 self ._parse_setting (data )
1920
20- def init_empty_config_content (self ):
21+ def init_empty_config_content (self ) -> None :
2122 if os .path .isfile (self .path ):
2223 with open (self .path , "rb" ) as input_toml_file :
2324 parser = parse (input_toml_file .read ())
@@ -27,10 +28,10 @@ def init_empty_config_content(self):
2728 with open (self .path , "wb" ) as output_toml_file :
2829 if parser .get ("tool" ) is None :
2930 parser ["tool" ] = table ()
30- parser ["tool" ]["commitizen" ] = table ()
31+ parser ["tool" ]["commitizen" ] = table () # type: ignore
3132 output_toml_file .write (parser .as_string ().encode (self .encoding ))
3233
33- def set_key (self , key , value ) :
34+ def set_key (self , key : str , value : Any ) -> Self :
3435 """Set or update a key in the conf.
3536
3637 For now only strings are supported.
@@ -39,7 +40,7 @@ def set_key(self, key, value):
3940 with open (self .path , "rb" ) as f :
4041 parser = parse (f .read ())
4142
42- parser ["tool" ]["commitizen" ][key ] = value
43+ parser ["tool" ]["commitizen" ][key ] = value # type: ignore
4344 with open (self .path , "wb" ) as f :
4445 f .write (parser .as_string ().encode (self .encoding ))
4546 return self
0 commit comments